Development questions

Explain all Trigger context variables (isInsert, isUpdate, isDelete, isUndelete, isBefore, isAfter, isExecuting, size, operationType).

  • Trigger.isInsert / isUpdate / isDelete / isUndelete: true if the trigger fired for that DML event.
  • Trigger.isBefore / isAfter: true for the before or after phase.
  • Trigger.isExecuting: true if the current code context is a trigger (also true when called from a method invoked by a trigger).
  • Trigger.size: total number of records in the invocation (old and new).
  • Trigger.operationType: a System.TriggerOperation enum (BEFORE_INSERT, AFTER_UPDATE, etc.) that can be used in a switch statement.
  • Data variables: Trigger.new, Trigger.old, Trigger.newMap, Trigger.oldMap.
apex-triggertriggercontext-variables