Context variables in triggers
Context variables in triggers
At Trigger we have 12 types of context variables that fire on the trigger:
- IsInsert:- Returns true if this trigger was fired due to an insert operation, from the Salesforce user interface, Apex, or the API.
- IsUpdate:- Returns true if this trigger was fired due to an update operation, from the Salesforce user interface, Apex, or the API.
- IsDelete:- Returns true if this trigger was fired due to a delete operation, from the Salesforce user interface, Apex, or the API.
- IsBefore:- Returns true if this trigger was fired before any record was saved.
- IsAfter:- Returns true if this trigger was fired after all records were saved.
- IsUndelete:- Returns true if this trigger was fired after a record is recovered from the Recycle Bin.
- New:- Returns a list of the new versions of the sObject records. This sObject list is only available in insert, update, and undelete triggers, and the records can only be modified in before triggers.
- NewMap:- A map of IDs to the new versions of the sObject records. This map is only available in before update, after insert, after update, and after undelete triggers.
- Old:- Returns a list of the old versions of the sObject records. This sObject list is only available in update and deletes triggers.
- OldMap:- A map of IDs to the old versions of the sObject records. This map is only available in update and delete triggers.
- Size:- The total number of records in a trigger invocation, both old and new.
- IsExecuting:- Returns true if the current context for the Apex code is a trigger, not a Visualforce page or a Web service.
Comments
Post a Comment