Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. trigger ContactAfterTrigger on Contact (after insert) {
  2. List<Contact> consToUpdate = new List<Contact>();
  3.  
  4. for(Contact conInTrigger : trigger.new){
  5. Contact c = new Contact();//Create a new instance of an as-yet-unidentified Contact
  6. c.Id = conInTrigger.Id;//Set that Contact's ID to an existing ID from the Contacts in Trigger.new
  7. c.Department = 'IT';//Change a field value on that Contact
  8. consToUpdate.add(c);//Add it to our List so we can update it later when all Contacts in Trigger.new have been prepared
  9. }
  10. update consToUpdate;//Perform the DML update call outside of our for-loop to avoid Governor Limits (150 DML per transaction)!
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement