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 protected] , Custom Type on [email protected]. Now, email id of Primary Contact's is updated to [email protected] , so Custom Type on Account0 [email protected] , 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 protected] . 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?

  • I don't think Scenario 1's custom_type__c is a formula field. Changes to the values of formula fields do not fire triggers. Is this value updated by a trigger, or perhaps a workflow rule or process?
    – David Reed
    May 7, 2019 at 12:53
  • In Scenario 1, custom_type__c = Primary_Contact__r.Email ,is a formula field. Primary Contact is lookup to contact , on account. I update email id on Primary Contact manually , which in turn updates custom type with the new value, and trigger on account fires. May 7, 2019 at 13:41

1 Answer 1


This is the expected behavior. In Account trigger only changes to Account trigger Context records can be checked.

Therefore, if you want to handle changes for Primary_Contact fields, please consider writing code in Contact trigger (presumably Primary_Contact__c is a lookup to Contact).


Scenario 1:

  1. Contact Record is updated.
  2. Contact triggers are run.
  3. Contact record changes are committed.
  4. Account trigger is triggered. Here old values for the Contact are not present.

Scenario 2:

  1. Account record is updated.
  2. Account trigger is run. Old values for the formula are present because it references Account fields.
  3. Account record changes are committed
  • Yes. It makes sense. May 7, 2019 at 17:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .