Salesforce Order Of Execution
There's quite a lot of options when it comes to implementing business logic in Salesforce. When pressing the "Save" button each of these options is triggered in a specific order that is important to know and remember.
In most cases, you wouldn't know the difference. But when you start using several business logic components on the same object it all becomes relevant. Take for example a Case object configured with Escalation Rules, adding a set of Validation Rules and again one or several Workflow Rules may lead to unexpected behaviours. Unless you master the Order Of Execution...
Below is the simplified sequence:
- 😈 System validation rules
- ⏪ Apex before triggers
- ✔️ Custom validation rules
- ⏩ Apex after triggers
- 👨👩 Assignment rules
- ♻️ Auto-response rules
- 🚀 Workflow rules
- 🍄 Process
- 📟 Escalation rules
- 🔎 Roll-up summary fields
Related Posts & Resources
- Salesforce: Apex Developer Guide
- Alba Rivas: Triggers and Order of Execution
- Johan Yu: "Validation Rule in Workflow and Process Builder"
- Ashish Agarwal: "Order of Execution (Rules, Triggers etc.)"
- Brian Cline: Salesforce Order of Execution
- Alba Rivas: Visualforce Order of Execution 1
I hope you enjoyed this post. Don't hesitate to ping me on Twitter if you have any comment or question. Bye for now!