Development questions
How do Platform Events and Change Data Capture (CDC) triggers differ from standard SObject triggers?
Standard SObject triggers fire synchronously on DML, support before and after events and all operations, run in the user's transaction.
Platform Event triggers (MyEvent__e) support only after insert, run asynchronously in a separate transaction as the Automated Process user, and fire when an event is published. They can be configured with a running user and checkpointed for retries.
CDC triggers (AccountChangeEvent) also support only after insert; they receive change events with a header (EntityName, ChangeType, RecordIds, ChangedFields) after the record is committed.
Both are asynchronous, decoupled, and cannot block the original save.
apex-triggertriggerplatform-eventscdc
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?