function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

can anyone explain trigger.ola and trigger.oldmap

hello every one can anyone explain  and define   trigger.old and trigger.oldmap in detail.because i didnt find anywhere



Best Answer chosen by Admin (Salesforce Developers) 

Trigger.old is the collection of the records being operated on in the trigger operation that represent what the database had at the time the operation initiated and does not reflect any changes being made in the context of the operation, hence the "old" values.


Trigger.oldMap returns the same collection as above as a map of id => sobject instead of an array. This is useful when you iterate over the collection of (in an update) and need to quickly correlate the new record (with values as the user changed them) with the old image.