I have scenario 1 - A formula field on Account (custom_type__c) which references the Contact's email as -
Primary_Contact__r.Email Whenever Primary Contact's email id is changed , Custom Type is updated on Account, which fires account trigger. However, Trigger.Old doesn't retain the old values.
Example- If Primary Contact's email id is email@example.com , Custom Type on Accountfirstname.lastname@example.org. Now, email id of Primary Contact's is updated to email@example.com , so Custom Type on Account0 firstname.lastname@example.org , which fires account trigger. When I print below-
System.debug('In After Update NEW ' + a.custom_type__c);
System.debug('In After Update Old ' + Trigger.OldMap.get(a.Id).custom_type__c)
Both the above statements email@example.com . 1)Why Trigger.OldMap() doesn't retain the old values?
I have scenario 2- I have changed the reference of the same formula field(custom_type__c) to the account name.Now Custom_Type__c = Name (Refers name of the account), in this case Trigger.OldMap retains the old values of the name.Why does it retain in scenario 2 but not in scenario 1?