What are the Apex trigger context variables and when is each available?
Suggested answer
Trigger context variables: Trigger.new — List of new record versions (available in insert, update, undelete). Trigger.old — List of old record versions (available in update, delete). Trigger.newMap — Map of Id to new record (available in before update, after insert, after update, after undelete). Trigger.oldMap — Map of Id to old record (available in update, delete). Trigger.isInsert / isUpdate / isDelete / isUndelete — Boolean flags for the operation type. Trigger.isBefore / isAfter — Boolean flags for timing. Trigger.size — Number of records in the current batch. In before triggers, Trigger.new records are mutable (you can set field values directly without DML). In after triggers, they are read-only.
Practice content for interview preparation; not an official vendor answer. Verify details against current product documentation.
Community comments (0)
No comments yet.
Sign in or create a free account to add a comment. Comments are moderated before they appear.