Trigger context variables in salesforce
Context variables are special variables provided by Salesforce to give information about how and when a trigger was run.
Developers can use these variables to determine the context in which the apex code is running and control the flow of execution accordingly.
isExecuting
Returns true if the current context for the Apex code is a trigger, not a Visualforce page, a Web service, or an executeanonymous() API call.
Trigger.isExecuting
isInsert
Returns true if the trigger was fired due to an insert operation.
Trigger.Insert
isUpdate
Returns true if the trigger was fired due to an update operation.
Trigger.isUpdate
isDelete
Returns true if the trigger was fired due to a delete operation.
Trigger.isdelete
isBefore
Returns true if the trigger was fired before any records were saved.
Trigger.isBefore
isAfter
Returns true if the trigger was fired after records were saved.
Trigger.isAfter
new
Returns a list of the new versions of the sObject records.
Trigger.new
newMap
A map of IDs to the new versions of the sObject records.
Trigger.newMap
old
Returns a list of the old versions of the sObject records.
Trigger.old
oldMap
A map of IDs to the old versions of the sObject records.
Trigger.oldMap