+ Start a Discussion
sudhakar reddy 13sudhakar reddy 13 

diff b/w trigger.new and trigger.old with one example

Abhishek BansalAbhishek Bansal
Hi,

Trigger.new will store the list of records with the new values and it is not available if delete context since we do no have anything new in case of delete.

Trigger.old will store the list of records with the old values and it is only available in update and delete context because there is nothing old while inserting a record.

For eg : Lets suppose you are changing the name of Contact from ABC to XYZ than trigger.new will contain XYZ and ABC will be stored in trigger.old.

You can find more details about context varibales in link given below :
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_context_variables.htm

Regards,
Abhishek.