Development questions
Under what user context do Apex Triggers run (System Mode vs User Mode)?
Apex triggers run in system mode: object permissions (CRUD) and field-level security of the current user are not enforced, so the trigger can read and write data the user can't.
Record sharing is not enforced by default either; sharing depends on the declaration of the handler classes (with sharing, without sharing, or inherited). To enforce user permissions explicitly, use WITH USER_MODE, Security.stripInaccessible(), or AccessLevel.USER_MODE in DML.
apex-triggertriggersecuritysharing
More Development questions
- What is an Apex Trigger in Salesforce and when should you use it over Flows?
- What is the difference between before triggers and after triggers?
- Explain all Trigger context variables (isInsert, isUpdate, isDelete, isUndelete, isBefore, isAfter, isExecuting, size, operationType).
- What is the difference between Trigger.new and Trigger.old?
- In which trigger events are Trigger.new and Trigger.newMap available?
- In which trigger events are Trigger.old and Trigger.oldMap available?