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
Rohit Vaidya 3Rohit Vaidya 3 

execution order

if i have flow and a trigger what will execute first and what is the correct order of execution in salesforce?
Arun Kumar 1141Arun Kumar 1141
Hi
If it run before the record is saved then the record-triggered flow executes first and after that before triggers executes. If it run after the record is saved then the after trigger executes first and after that the record-triggered flow executes. For information you can check on below link
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_order_of_execution.htm
Please mark it as best answer if this helps

Thanks
Arun
Smith543 ThomasSmith543 Thomas
If it run before the record is saved then the record-triggered flow executes first and after that before triggers executes in . If it run after the record is saved then the after trigger executes first and after that the record-triggered flow executes https://validwords.com/. For information you can check on below link
SubratSubrat (Salesforce Developers) 
Hello Rohit ,

In Salesforce, actions are executed in a specific order. Here's a sample scenario: 

You want to set up an auto-response rule for email-to-case cases. You define the criteria as:

Order 1 - Criteria: Case: ABC Equals XYZ - Send from(Email): XYZ - Template: Auto response XYZ.
Order 2 - Criteria: Blank - Send from(Email): 2XYZ - Template: 2Auto response XYZ

Process Builder will trigger whenever EmailMessage Isincoming: True. Process Builder should update the Case field (ABC) with the XYZ value. 

You expect auto-response Order 1 to fire, but Order 2 fires instead. This is due to the order in which actions execute in Salesforce.

In Salesforce, this is the order in which actions execute:

1. System Validation Rules
2. Apex Before Triggers
3. Custom Validation Rules
4. Duplicate Rules
5. Apex After Triggers
6. Assignment Rules
7. Auto-Response Rules
8. Workflow Rules
9. Processes
10. Escalation Rules
11. Roll-Up Summary Fields

Reference -> https://help.salesforce.com/s/articleView?id=000383414&type=1 (https://help.salesforce.com/s/articleView?id=000383414&type=1)

If this helps , please mark this as Best Answer,
Thank you.