Development questions
When should you use Queueable Apex instead of @future methods inside a trigger handler?
Prefer Queueable over @future in almost all cases:
- Accepts SObjects and complex types (future allows only primitives)
- Returns a job Id for monitoring
- Supports chaining jobs
- Can be called from other async contexts (limited chaining), whereas future cannot be called from future/batch
- Easier to test and to add
Finalizers
Use @future only for very simple fire-and-forget logic or legacy code, and for Mixed DML separation when simplicity matters. Watch the limit of 50 jobs enqueued per transaction (1 from async).
apex-triggertriggerasyncqueueable
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?