Skip to content

Instantly share code, notes, and snippets.

@AlwaysThinkin
Created September 28, 2016 21:31
Show Gist options
  • Save AlwaysThinkin/c68303bf6e14a859f0d34a34824c77a5 to your computer and use it in GitHub Desktop.
Save AlwaysThinkin/c68303bf6e14a859f0d34a34824c77a5 to your computer and use it in GitHub Desktop.

Revisions

  1. AlwaysThinkin revised this gist Sep 28, 2016. 2 changed files with 0 additions and 0 deletions.
    File renamed without changes.
    File renamed without changes.
  2. AlwaysThinkin created this gist Sep 28, 2016.
    12 changes: 12 additions & 0 deletions ContactAfterClass
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    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;
    }
    }
    12 changes: 12 additions & 0 deletions ContactAfterInsert trigger
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    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;
    */
    }