When you work in Salesforce long enough, you quickly realize that saving a record is never just saving a record. Behind the scenes, Salesforce follows a specific and complex sequence of events, commonly known as an “Order of Execution”, that determines how workflows fire, which triggers run first, how validations behave, and why certain automation conflicts occur.
Miss one detail, and you might spend hours debugging unexpected errors, failing test scenarios, or automation loops that seem to appear out of nowhere.
In this blog, we will discuss the Salesforce Order of Execution in a way that’s easy to follow, showing each step in order and explaining why it matters for admins and developers. By the end, you’ll know exactly what happens, when it happens, and how to design automation that works together instead of working against you.
Step-By-Step SFDC Order of Execution
When you save a record, the server goes through the following stages:
- Initialize the record for an upsert statement or load the actual record from the database.
- Overwrite the previous values and load the updated record field values from the request. Salesforce does system validation to look for the following if the request originated from a typical UI update page:
- Adherence to layout-specific guidelines
- Values that are necessary at the field definition and layout levels
- Acceptable formats for fields
- Field length maximum
Salesforce only verifies the foreign keys when the request originates from another source, like an Apex application or a SOAP API call. It confirms that any custom foreign keys do not refer to the actual object before launching a trigger. If multiline items, like quote and opportunity line items, were produced, Salesforce used custom validation criteria.
- Run flows that are triggered by records and set up to run prior to the record being saved.
- Run every before trigger.
- Rerun the majority of system validation procedures, including any custom validation rules, and confirm that all necessary fields have a non-null value. The implementation of layout-specific criteria is the sole system validation that Salesforce does not do again (when the request originates from a typical UI modification page).
- Put duplicate rules into action. The record is not saved and no more actions (such as following triggers and workflow rules) are performed if the duplicate rule determines that the record is a duplicate and applies the block action.
- Don’t commit just yet, but save the record to the database.
- Run everything after the triggers.
- Follow the assignment guidelines.
- Put auto-response rules into action.
- Execute workflow rules. Update the record once again if there are any field updates. Repeat the system validations. Duplicate rules, processes, escalation rules, flows, and custom validation rules are not executed again. Run both before and after update triggers one more time, regardless of whether the record operation is an update or insert.
- Follow the escalation rules.
- Perform the Salesforce Flow automations listed below, though not necessarily in that order:
- Procedures
- Process-initiated flows
- Workflow rules initiate flows (flow trigger workflow actions pilot).
- The impacted record goes through the save process when a DML operation is carried out by a process or flow.
- Run flows that are triggered by records and are set up to start when the record is stored.
- Put entitlement rules into action.
- Make computations and update the roll-up summary field in the parent record if the record has one or if it is a part of a cross-object process. The parent record undergoes a saving process.
- Make calculations and update the roll-up summary field in the grandparent record if the parent record has been updated and the grandparent record has a roll-up summary field or is a part of a cross-object process. The save process is then applied to the grandparent record.
- Conduct a sharing evaluation based on criteria.
- All DML actions should be committed to the database.
- Run the post-commit logic once the modifications have been committed to the database.
Crucial Aspects of the Order of Execution
The addition of flows is the most significant modification to Salesforce’s Order of Execution in recent releases. These are the key factors and modifications that were mentioned in the Spring ’22 release.
1. Validation
- System validation verifies the length and type of fields, as well as the values in necessary fields.
- System validation provides page layout-specific settings for Edit/Read-only fields whenever the record is altered in the user interface.
- Every record save is subject to an evaluation of all active validation rules.
- Duplicate rules and custom validation rules only execute once.
2. After Triggers, Assignment, and Auto-Response Rules Execute
Records will be automatically assigned to particular queues or users based on assignment rules. Based on predetermined criteria, your auto-response rules will automatically respond.
- The custom code logic is used to further update the records.
- The record owner is updated by assignment rules in accordance with the first rule that corresponds to your record.
- Assignment rules execute upon creation or upon record updates if they are called via Apex.
- When a record is created, auto-response rules are activated, preparing the email to be sent in accordance with the first rule that corresponds to your record.
- You are unable to control the sequence in which triggers fire if each object has more than one trigger.
3. Process Builders, Approval Procedures, and Workflow Rules Operate
You may utilize point-and-click tools to automate your operations with Process Builder and Flows. To avoid any performance problems, make sure your procedures and flows are effective. recognizing and constructing triggers in accordance with the sequence in which they are executed, whether before or after. The one-trigger-per-object approach is the ideal way to create your triggers.
- Every record save is subject to an evaluation of all active workflow rules.
- Workflows are used for approvals.
- Field updates are carried out prior to any other activities in accordance with workflow standards.
- Every record saving is assessed for all active Process Builders.
- All WFR/AP/PB that did not run once are re-evaluated up to five times for each field change that triggers re-evaluation.
- For every cycle, every workflow rule and Process Builder field modifies records that result in system validation, before triggers, and after triggers.
- Similar to triggers, you are unable to control the sequence in which WFR/AP/PBs operate.
To avoid creating an infinite loop, keep trigger recursion in mind when building your triggers by utilizing static variables and other strategies. To avoid only running on one record at a time, your triggers should be able to handle several records simultaneously.
4. Rules for Workflow
Simple field changes and email alerts can be created using processes; complicated logic should not be used. Rather, assign any intricate reasoning to your Apex triggers or procedures. Be careful when implementing governor limits because they place restrictions on your operations and resources in a single transaction. To avoid performance problems or exceptions, your code should adhere to these restrictions.
5. Before Save and After Save Flows
- Before-save flows are executed immediately following system validation.
- Flows are carried out just once for each entity and transaction.
- For record saves, only flows that meet the entry conditions are executed.
- Set the same object’s running order.
- Time-based field updates only execute flows and are a distinct transaction.
- Similar types of flows go in the order that the flow specifies. Run flows with an order of 1–1000 first, followed by flows without an order. The flows were then arranged 1001-2000.
6. Routing Omni
- Triggers, workflow rules, approval procedures, and escalation rules do not operate when work is routed and assigned.
- The regular operations begin after the record has been edited and saved once again.
Use the Salesforce Order of Execution to your advantage because you will eventually encounter clicks with code in most organizations.
Get Expert Salesforce Guidance for Your Business From Sailwayz
Automation that fires in the right sequence can make the difference between a flawless process and hours spent debugging unexpected errors. Understanding Salesforce’s Order of Execution helps, but having a partner who designs automation that works perfectly together helps even more.
At Sailwayz, our certified experts guide you through every step of your Salesforce journey, aligning processes with strategy so your CRM becomes a powerful engine for growth.
What you gain with a Sailwayz Consultation:
- Tailored Salesforce automation strategy aligned with your business goals
- Guidance to prevent workflow conflicts and trigger issues
- Streamlined processes that boost productivity and user adoption
- Expert insights into scalable and future-proof architecture
Your business deserves a Salesforce setup that performs without friction and a team that supports you long after implementation day. Sailwayz ensures every workflow, integration, and data rule works to accelerate success.
Let’s design automation that helps your business run smarter.
Schedule a Free Consultation