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
SS KarthickSS Karthick 

Regarding Trigger

Hi Everyone,
      Can anyone tell me what is trigger.new, trigger.old and trigger.newmap ,trigger.oldmap
Trigger.oldmap.keyset with sample example


Thanks in advance
Karthick

Best Answer chosen by SS Karthick
Ravi NarayananRavi Narayanan

Trigger.new == list of new versions of Sobjects

Trigger.old==list of old versions of Sobjects

Trigger.newMap == Map of Id and new version of Sobject.

Trigger.oldMap==map of id and old version of SObject

 

=================================

I am modifying one field called country in Account object from USA to INDIA.

Now trigger.new will contain all the fields of that account where the value of country field as INDIA and trigger.old will contain USA.

Trigger.newMap will contain ---    accountid and all the fields of that account with fieldvalue of country as USA.

trigger.oldmap will contain -- accountid and all the fields of that account with fieldvalue of country INDIA 

All Answers

Ravi NarayananRavi Narayanan

Trigger.new == list of new versions of Sobjects

Trigger.old==list of old versions of Sobjects

Trigger.newMap == Map of Id and new version of Sobject.

Trigger.oldMap==map of id and old version of SObject

 

=================================

I am modifying one field called country in Account object from USA to INDIA.

Now trigger.new will contain all the fields of that account where the value of country field as INDIA and trigger.old will contain USA.

Trigger.newMap will contain ---    accountid and all the fields of that account with fieldvalue of country as USA.

trigger.oldmap will contain -- accountid and all the fields of that account with fieldvalue of country INDIA 

This was selected as the best answer
Ravi NarayananRavi Narayanan
http://www.infallibletechie.com/2013/01/triggerold-example-in-salesforce.html
SamuelDeRyckeSamuelDeRycke
Have you read the documentation ?   https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_triggers_context_variables.htm

Rather than helpign for samples, it would be meaningfull if you express what you don't understand and why, so the answer could be more specific to helping you out.
Anky KolaAnky Kola
Thanks for your questions and answer.
best good morning quotes (https://lovequotes.co.in/good-morning-quotes/) and cute good night quotes (https://lovequotes.co.in/good-night-quotes/)