• Matt O'Hara
  • NEWBIE
  • 0 Points
  • Member since 2014
  • CRM Administrator
  • Thermo Fisher Scientific

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
I'm new to development but have been watching Intro to Apex webinars and I think I have a good foundation to write my first Trigger. Before I get started I'd like to make sure that I'm heading in the right direction.

I have a number of fields on Accounts that are updated via a Process when the Billing Address Postal/Zipcode field changes. Rep1, Rep2, Rep3, etc. This works fine. I need a Trigger that updates the Territories. The Territory rules just look at the field values for Rep1, Rep2, Rep3, etc.

I think that I'm tring to do an "after update, after insert" Trigger, but I don't know what I'm trying to update. Is it AccountShare?

Thanks in advance!
Our org shares Contact and Account Objects across Users, and so we have locked down some things like a User's ability to deactivate a Contact. So they make these requests of the admin team, and we go in and deactivate the Contact. The issue is that there are a bunch of fields that need to be updated and it's a lot of clicks. I created a Javascript Custom Button to make easy work of this. The problem is that I don't want to create a new Page Layout just for the admin team to use this button.

I don't know enough about Javascript to A) know if this is possible via a bookmarklet and B) modify my code to make it work via a bookmarklet (I cobbled this together looking at other peoples' work). I know I need to change the double quotes to single, and maybe encode the URI. How do I include the library? Here is what I have currently:

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var c = new sforce.SObject("Contact");
c.id = "{!Contact.Id}";
c.Request_to_Change__c = null;
c.Reason_for_Inactivation__c = null;
c.Request_to_Change_Detail__c = null;
c.Active_Contact__c = "False";
c.Contact_status__c = "Inactive";
result = sforce.connection.update([c]);

window.location.reload();
I'm new to development but have been watching Intro to Apex webinars and I think I have a good foundation to write my first Trigger. Before I get started I'd like to make sure that I'm heading in the right direction.

I have a number of fields on Accounts that are updated via a Process when the Billing Address Postal/Zipcode field changes. Rep1, Rep2, Rep3, etc. This works fine. I need a Trigger that updates the Territories. The Territory rules just look at the field values for Rep1, Rep2, Rep3, etc.

I think that I'm tring to do an "after update, after insert" Trigger, but I don't know what I'm trying to update. Is it AccountShare?

Thanks in advance!

Hi,

I am trying to automatically assign a new user to a Chatter Group called 'Everyone'.  The code below works as long as I do not select a role; however, when I select a role I get the following error.  Does anyone have a clue what this error means or if there is a code that can do what I am trying to do?

 

22:29:46.425
(425800000)|EXCEPTION_THROWN|[24]|System.DmlException: Insert failed.
First exception on row 0; first error: MIXED_DML_OPERATION, DML
operation on setup object is not permitted after you have updated a
non-setup object (or vice versa): CollaborationGroupMember, original
object: User: []
22:29:46.426
(426685000)|FATAL_ERROR|System.DmlException: Insert failed. First
exception on row 0; first error: MIXED_DML_OPERATION, DML operation on
setup object is not permitted after you have updated a non-setup object
(or vice versa): CollaborationGroupMember, original object: User: []

 

 

 

trigger User_trigger on User (after insert, before insert, after update, before update) {
    if ( Trigger.isInsert ) {    
        if ( Trigger.isAfter ) {
            List<CollaborationGroupMember> cgm = new List<CollaborationGroupMember>();              
            Id cgID = [ Select Id 
                      FROM CollaborationGroup 
                      WHERE Name = 'Everyone' LIMIT 1 ].ID;
System.debug('zzz: ' + cgID);    
            for ( user u: Trigger.new ) {
                cgm.add(new CollaborationGroupMember (CollaborationGroupId = cgID, MemberId = u.id));    
            }    
            insert cgm;          
        }
    }
}