Posts

Trigger Scenario 6

  Trigger Scenario 6   : When ever Opportunity "Stage" is modified to "Closed Won" then set "Close Date" as "Today Date" and "Type" as "New Customer". Object : Opportunity Trigger: Before Update Trigger Code : OpportunityUpdate.apxt 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 trigger OpporUpdate on Opportunity (before update) {             Map<Id,Opportunity> oppOld = Trigger.oldMap;             Map<Id,Opportunity> oppNew = Trigger.newMap;             Set<Id> keys =oppOld.keySet();             for (Id rid :keys){                     Opportunity oldOpportunity = oppOld.get(rid);                   ...

Trigger - Create contact when new account created

Image
  Trigger - Create contact when new account created Another Example: Trigger Code : CreateAccountContact.apxt 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 trigger CreateAccountContact on Account (after insert) {             list<contact> contacts = new list<contact>();             for (account acc : trigger. new ){                     if (acc.Industry == 'Banking' ){                             contact con = new contact();                             con.LastName = acc.name;          ...