Salesforce Order of Execution

Before designing any functionality, its important to understand what is the order of execution of different automation tools Salesforce offers. Lets check!

We, being developers, very much aware about automation tools like process builders, Workflows, triggers etc, but ignore what is their order of execution. Before designing any functionality, one should understand the order of execution Salesforce has defined. Here I have listed down the order of execution in most simple way so that it will be helpful to remember.

  1. Loads a record : User fills the information and hit on save button, Salesforce loads this information to perform further actions.
  2. System validation rules : If user is entering information directly from UI, following checks are applied
    • Layout-specific rules
    • Required values
    • Field formats
    • Maximum field length
  3. Custom Validation rules : validation rules present on the object.
  4. Before Triggers : All before insert, before update, before delete triggers.
  5. Duplicate Rules.
  6. Saves into database : Record is saved into database (not commited). ID of record is generated in this step.
  7. After Triggers : All after insert, after update, after delete, after undelete triggers are executed.
  8. Assignment Rules.
  9. Auto-response Rules.
  10. Workflow Rules : If any field is updated with workflow, validation rules are not fired again. But before and after triggers are fired again.
  11. Process builder flows : All custom validation rules and triggers related to object are fired again.
  12. Escalation Rules
  13. Entitlement Rules
  14. Rollup summary calculation : if there is roll up summary calculation happening on parent record, it also goes through save procedure (Same order of execution performed for parent record)
  15. Criteria based sharing rules.
  16. Commit record information to database

It’s hard to remember all the steps in sequence, so you can try by remebering the abbrevations. Like I remember this as VBD – AAA – WP – EE – RCC

  • V (Validations) B (Before Triggers) D (Deplicate Rules)
  • A (After Triggers) A (Assignment Rules) A (Auto Response Rules)
  • W (Workflows) P (Process Builder Flows)
  • E (Escalation Rules) E (Entitlement Rules)
  • R (Rollup Summary) C (Criteria based sharing rules) C (Commit to database)

This is the most common question in any Salesforce interview process, so if you are looking for any job change, I suggest you should know this order or execution.

if you want more detailed explaination, Salesforce has already posted detailed explaination of the order of execution, you can check it out here.