Trigger Context Variables
Thought of writing a article around the context variables present in triggers.
Before Insert :
Trigger.new would be available as new values are being inserted into the database
Trigger.old would not be available as fresh records are being inserted into the database
Trigger.newMap would not be available as the record id's are not generated in before insert event
Trigger.oldMap would not be available as the record id's are not generated in before insert event
After Insert :
Trigger.new would be available as new values are being inserted into the database
Trigger.old would not be available as fresh records are being inserted into the database
Trigger.newMap would be available as the record id's are generated in after insert event
Trigger.oldMap would not be available as fresh records are being inserted into the database
Before Update :
Trigger.new would be available containing the updated values
Trigger.old would be available containing the old values
Trigger.newMap would be available containing the updated values
Trigger.oldMap would be available containing the old values
After Update :
Trigger.new would be available containing the updated values
Trigger.old would be available containing the old values
Trigger.newMap would be available containing the updated values
Trigger.oldMap would be available containing the old values
After Delete :
Trigger.new would not be available as there is not update or insert performed
Trigger.old would be available containing the old values
Trigger.newMap would not be available as there is not update or insert performed
Trigger.oldMap would be available containing the old values
After Undelete :
Trigger.new would be available as records are restored from recycle bin
Trigger.old would not be available as this is similar to an insert event
Trigger.newMap would be available as records are restored from recycle bin
Trigger.oldMap would not be available as this is similar to an insert event
Before Insert :
Trigger.new would be available as new values are being inserted into the database
Trigger.old would not be available as fresh records are being inserted into the database
Trigger.newMap would not be available as the record id's are not generated in before insert event
Trigger.oldMap would not be available as the record id's are not generated in before insert event
After Insert :
Trigger.new would be available as new values are being inserted into the database
Trigger.old would not be available as fresh records are being inserted into the database
Trigger.newMap would be available as the record id's are generated in after insert event
Trigger.oldMap would not be available as fresh records are being inserted into the database
Before Update :
Trigger.new would be available containing the updated values
Trigger.old would be available containing the old values
Trigger.newMap would be available containing the updated values
Trigger.oldMap would be available containing the old values
After Update :
Trigger.new would be available containing the updated values
Trigger.old would be available containing the old values
Trigger.newMap would be available containing the updated values
Trigger.oldMap would be available containing the old values
After Delete :
Trigger.new would not be available as there is not update or insert performed
Trigger.old would be available containing the old values
Trigger.newMap would not be available as there is not update or insert performed
Trigger.oldMap would be available containing the old values
After Undelete :
Trigger.new would be available as records are restored from recycle bin
Trigger.old would not be available as this is similar to an insert event
Trigger.newMap would be available as records are restored from recycle bin
Trigger.oldMap would not be available as this is similar to an insert event
Comments
Post a Comment