Activity › Forums › Salesforce® Discussions › When to use newMap and oldMap in Salesforce?
-
When to use newMap and oldMap in Salesforce?
Posted by Anjali on April 29, 2020 at 12:59 PMWhen to use newMap and oldMap in Salesforce?
Marziya replied 6 years, 1 month ago 5 Members · 4 Replies -
4 Replies
-
Trigger.OldMap: Trigger.oldMap returns map of old records which are updated with new values. These List of records already there in Database. Trigger.oldmap available in Before update, after update, Before Delete and After Delete triggers.
Trigger.NewMap: Trigger.newMap returns map of new records which are trying to insert into Database. This is available in Before Insert, Before Update, After Insert, After Update Triggers and undelete Triggers. This list of records can only modified in Before triggers. - [adinserter block='9']
-
Trigger.newMap: It is a map with key as ID of the record and value as the record itself. In case of accounts when we say trigger.newMap we are talking about a map of key-value pairs where the key is the account ID and the value is the account record itself.
Trigger.OldMap: A map of IDs to the old versions of the sObject records. Note that this map is only available in update and delete triggers. -
Trigger.oldmap available in Before update, after update, Before Delete and After Delete triggers.
Trigger.newMap This is available in Before Insert, Before Update, After Insert, After Update Triggers and undelete . -
when we say trigger.newMap we are talking about a map of key-value pairs where the key is the account ID and the value is the account record itself.
Trigger.OldMap: A map of IDs to the old versions of the sObject records.
Log In to reply.