Skip to content

Instantly share code, notes, and snippets.

@AlwaysThinkin
Created September 28, 2016 21:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlwaysThinkin/c68303bf6e14a859f0d34a34824c77a5 to your computer and use it in GitHub Desktop.
Save AlwaysThinkin/c68303bf6e14a859f0d34a34824c77a5 to your computer and use it in GitHub Desktop.
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;
}
}
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