Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trigger ContactAfterTrigger on Contact (after insert) {
- List<Contact> consToUpdate = new List<Contact>();
- for(Contact conInTrigger : trigger.new){
- Contact c = new Contact();//Create a new instance of an as-yet-unidentified Contact
- c.Id = conInTrigger.Id;//Set that Contact's ID to an existing ID from the Contacts in Trigger.new
- c.Department = 'IT';//Change a field value on that Contact
- consToUpdate.add(c);//Add it to our List so we can update it later when all Contacts in Trigger.new have been prepared
- }
- update consToUpdate;//Perform the DML update call outside of our for-loop to avoid Governor Limits (150 DML per transaction)!
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement