Monday, October 28, 2019

AVAILABILITY OF TRIGGER.NEW, TRIGGER.OLD, TRIGGER.NEWMAP, TRIGGER.OLDMAP

difference between trigger newmap and trigger oldmap in salesforce


WITH Before Insert, TRIGGER.NEWMAP is not available as we do not have the id of the record generated before the record is inserted, id gets generated when the record is inserted in the database.

WITH Before Insert, TRIGGER.OLD and TRIGGER.OLDMAP will not be available as we do not have any old data available. This will be  a new record that will get inserted in the database.

WITH After Insert, TRIGGER.OLD and TRIGGER.OLDMAP will not be available as we do not have any old data available. This is a new record that is inserted into the database.

WITH Before Update and After Update TRIGGER.NEW, TRIGGER.NEWMAP, TRIGGER.OLD  and TRIGGER.OLDMAP will be available as we will have new and old data.

WITH Before Delete and After Delete we will not have TRIGGER.NEW, TRIGGER.NEWMAP as we are not updating any data, we are just deleting the record.

WITH After Undelete we will have TRIGGER.NEW, TRIGGER.NEWMAP. Undelete event just restored the deleted record. Also, the id of the record remains the same after it is restored.

4 comments:

  1. Hi Very Good Explanation Thanks for sharing Knowledge with us ......

    ReplyDelete
  2. thank you a lot, explanation is very well. Understood very quickly.

    ReplyDelete
  3. This is the best blog I have ever seen to understood the trigger context variables. Very easy to learn and understand.

    ReplyDelete