function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Roushan kumar 10Roushan kumar 10 

Order of execution in salesforce

Is this the right order of execution in Salesforce with these options? If not please suggest. Thanks
1. system validation rules
2. Executes all before trigger
3. Custom Validation Rule
4. Execute all after trigger
5.Execute assignment rule
6. Execute Auto response rule
7. Execute workflow rule
8. Execute escalation rules

 
Best Answer chosen by Roushan kumar 10
Manoj DegaManoj Dega

Hi Roushan,

Pls, find below.

1. System Validation rule (required field, field format) (SV)
2. Before Triggers are executed (BT)
3. Custom Validation rules are checked (CV)
4. After Triggers are executed (AT)
5. Assignment Rules are executed (AR)
6. Auto-Response Rules are executed (ARR)
7. Workflow Rules are executed (WR)
8. Before and after triggers are executed one more time if the workflow rule updates a field (BT & AT)
9. Escalation Rules are executed (ER)
10. Parent Rollup Summary Formula or Cross Object Formula fields are updated in the respective objects. (RSF, COF) (These parent records also goes through the entire execution order)
11. Criteria Based Sharing rules are evaluated (CBS)
12. Any Post-Commit Logic is executed (PCL)  (like sending an email)

for more details: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm

If it helps you, please mark it as the best answer.
Thank you.
 

All Answers

Manoj DegaManoj Dega

Hi Roushan,

Pls, find below.

1. System Validation rule (required field, field format) (SV)
2. Before Triggers are executed (BT)
3. Custom Validation rules are checked (CV)
4. After Triggers are executed (AT)
5. Assignment Rules are executed (AR)
6. Auto-Response Rules are executed (ARR)
7. Workflow Rules are executed (WR)
8. Before and after triggers are executed one more time if the workflow rule updates a field (BT & AT)
9. Escalation Rules are executed (ER)
10. Parent Rollup Summary Formula or Cross Object Formula fields are updated in the respective objects. (RSF, COF) (These parent records also goes through the entire execution order)
11. Criteria Based Sharing rules are evaluated (CBS)
12. Any Post-Commit Logic is executed (PCL)  (like sending an email)

for more details: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm

If it helps you, please mark it as the best answer.
Thank you.
 

This was selected as the best answer
{tushar-sharma}{tushar-sharma}
Here we have a new addition here. We now have Before save flow which executes before triggers.
You can find updated details here: https://newstechnologystuff.com/2020/05/25/order-of-execution-in-salesforce/