Created
September 28, 2016 21:31
-
-
Save AlwaysThinkin/c68303bf6e14a859f0d34a34824c77a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ContactAfterInsert { | |
public static void setContactDeptIT(List<Contact> cons){ | |
List<Contact> consToUpdate = new List<Contact>(); | |
for(Contact conInTrigger : cons){ | |
Contact c = new Contact(Id = conInTrigger.Id, Department = 'IT'); | |
consToUpdate.add(c); | |
} | |
update consToUpdate; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Trigger ContactAfterTrigger on Contact (after insert) { | |
ContactAfterInsert.setContactDeptIT(trigger.new); | |
/*Logic Moved to ContactAfterInsert class | |
List<Contact> consToUpdate = new List<Contact>(); | |
for(Contact conInTrigger : trigger.new){ | |
Contact c = new Contact(Id = conInTrigger.Id, Department = 'IT'); | |
consToUpdate.add(c); | |
} | |
update consToUpdate; | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment