The after event

Then, we can update the after update part on the trigger (some parts of the code have been hidden for simplicity; refer to this book's GitHub repository for the full code):

 1. trigger OpportunityTrigger on Opportunity (before insert, before  2. update, after insert, after update) { 3.      4.     //current record (supposing only one opportunity can be saved at         once) 5.     Opportunity currentOpp =[0]; 6. 7.     //treating before and after events separately 8.     if(Trigger.isBefore){ 9.         //. . . hidden for brevity10.     }else if(Trigger.isAfter){11.         if(Trigger.isUpdate || Trigger.isInsert){12.13.             if(currentOpp.AccountId != null) {14.                 //query current account15.                 Account acc = [Select Id From Account 16. Where Id = :currentOpp.AccountId]; ...

Get Salesforce Advanced Administrator Certification Guide now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.