This small table is very helpful for the Beginner and Intermediate level Developers. It is also helpful for cracking the salesforce interviews. Basically it shows that in various Trigger events what does Sobject record collection hold. Here Sobject Records refers to below Trigger context variables.
- Trigger.new: Returns a list of the new versions of the sObject records.
- Trigger.newMap: A map of IDs to the new versions of the sObject records.
- Trigger.old: Returns a list of the old versions of the sObject records.
- Trigger.oldMap: A map of IDs to the old versions of the sObject records.
Trigger Events | Trigger.new | Trigger.newMap | Trigger.old | Trigger.oldMap |
Before Insert | ✔ | NULL | NULL | NULL |
After Insert | ✔ | ✔ | NULL | NULL |
Before Update | ✔ | ✔ | ✔ | ✔ |
After Update | ✔ | ✔ | ✔ | ✔ |
Before Delete | NULL | NULL | ✔ | ✔ |
After Delete | NULL | NULL | ✔ | ✔ |
After Undelete | ✔ | ✔ | NULL | NULL |