SHARE
TWEET

Untitled

a guest Jun 19th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top