You need to sign in to do that
Don't have an account?
Using Trigger.NewMap and Trigger.OldMap
Hello Guys,
Can anyone please give me a helpful explanation of when, how and why exactly do we use Trigger.Oldmap and Trigger.newMap.
Thanks in Advance!
You need to sign in to do that
Don't have an account?
Hello Guys,
Can anyone please give me a helpful explanation of when, how and why exactly do we use Trigger.Oldmap and Trigger.newMap.
Thanks in Advance!
Trigger.Oldmap and Trigger.newMap i use to compare the data on record after update, i mean the newMap contain al the data that you are updating, and the oldMap the data before the oupdate, so....
you can do something like
Id = record.Id;
if(newMap.get(Id).Is_Active__c != oldMap.get(Id).Is_Active__c){
Thats in my case, exist many other uses.
I hope helpful.
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.