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
Rabbani sayyed 8Rabbani sayyed 8 

What is the trigger.newmap and trigger.oldmap and when to use these two in triggers? can anyone share me the answer for this in detail?

What is the trigger.newmap and trigger.oldmap and when to use these two in triggers? can anyone share me the answer for this in detail?
Best Answer chosen by James Loghry
Frédéric TrébuchetFrédéric Trébuchet
Hi,

newMap and oldMap are just maps of ids where new and old are lists.
Here is the definition for each of the Trigger Context Variables https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_context_variables.htm.

Hope this helps,
Fred

All Answers

@anilbathula@@anilbathula@
Hi Rabbani sayyed 8

Go through this links when to use trigger.old and triigger.new and hw to use them?

https://help.salesforce.com/apex/HTViewSolution?id=000003789&language=en_US
http://www.sfdc99.com/2014/02/25/comparing-old-and-new-values-in-a-trigger/

Thanks
Anil.B
Frédéric TrébuchetFrédéric Trébuchet
Hi,

newMap and oldMap are just maps of ids where new and old are lists.
Here is the definition for each of the Trigger Context Variables https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_context_variables.htm.

Hope this helps,
Fred
This was selected as the best answer
James LoghryJames Loghry

To add on to Frederic's post, that page also lists when each map is available, which is especially important for triggers firing on insert and delete.

Frédéric TrébuchetFrédéric Trébuchet
Hi,

If these answers helped you solve your problem, please, mark the question as Solved and kindly select the best one ;)

Thanks,
Fred