Sub topic 14
Consolidating automation per object and controlling flow order
This chapter assumes you have inventoried your Workflow Rules and processes, and that you can build a basic record-triggered flow with entry conditions. It covers two decisions you make after the individual conversions: how many flows each object should have, and how to control the order they run in.
Why consolidation matters
A typical org has grown automation in layers. One Opportunity might have three Workflow Rules, two processes, and a trigger, all written by different admins. Converting each item one-to-one gives you five flows on the same object. They can all fire on the same save, and none of them knows about the others.
That creates three problems:
- Unpredictable results. Two flows can update the same field. The one that runs last wins, and without a defined order that can change between releases or deployments.
- Wasted limits. Each after-save flow that runs its own Get Records or DML (Data Manipulation Language, the create, update, and delete operations) on the same save uses part of the same transaction limits.
- Hard maintenance. To answer "what happens when an Opportunity closes?", you must open every flow.
Choose a consolidation pattern
There are two common patterns. Neither is always right.
| Pattern | Strength | Weakness |
|---|---|---|
| One flow per object per trigger type | Easy to find. Order inside the flow is explicit. | Large flows are harder to read, test, and deploy. Two admins editing it can collide. |
| One flow per business purpose, with trigger order | Small flows. Each can be tested and owned separately. | Order must be managed. Overlap between flows can go unnoticed. |
A practical middle path:
- Create at most one before-save flow per object for same-record field changes.
- Create after-save flows grouped by purpose, such as "Opportunity: Closed Won follow-up" and "Opportunity: Notifications".
- Use a Decision element inside a flow to separate outcomes. Reserve entry conditions for the broad test that applies to every path in that flow.
- Keep scheduled paths in the flow that owns the related immediate actions, so the logic for one business event lives together.
Merge criteria carefully
Merging changes how conditions behave. A Workflow Rule set to "only when created or edited to meet criteria" runs once when the record starts to match. If you merge it into a flow that runs on every update, it can fire repeatedly. Preserve the old behavior inside the merged flow with a prior-value comparison:
Decision outcome "Became Closed Won":
AND(
TEXT({!$Record.StageName}) = "Closed Won",
ISNEW() || TEXT({!$Record__Prior.StageName}) <> "Closed Won"
)The same test works in an entry condition, but a Decision outcome lets one flow handle several such conditions on the same object. Write each outcome so it matches exactly one old rule or process node. Then you can trace every migrated behavior back to its source.
When two old automations set the same field, decide the intended result now. Do not copy both and hope. Record the decision, because the winner is currently determined by the order of execution and you are about to change it.
Where flows run in the order of execution
Record-triggered flows run at two fixed points in a save. Salesforce does not let you move them.
Two consequences follow:
- Before-save flows always run before Apex triggers. After-save flows always run after them.
- During migration, a Workflow Rule and its replacement flow are not at the same point. A Workflow Rule runs before after-save flows. If a rule's field update changes data that a flow reads, removing the rule can change what the flow sees.
Control order with trigger order
Within one object and one trigger type, you can set a Trigger Order value on each record-triggered flow. In Flow Builder, open the Start element, then Advanced settings, and enter a number. Flows with lower numbers run first.
Rules for using it:
- Order applies only among flows on the same object and the same timing (before-save with before-save, after-save with after-save). It cannot put an after-save flow before a before-save flow.
- Use unique values with gaps, such as 100, 200, 300. You can insert a new flow at 150 later without renumbering.
- Do not rely on the order of flows that share a value or have none. Salesforce does not document that order as stable.
- Set an order on every flow for the object, not only the ones you are worried about. Flows without a value are placed relative to numbered ones in a way that is easy to misjudge.
See what runs with Flow Trigger Explorer
In Setup, open Flow Trigger Explorer, pick an object, and view its flows grouped by trigger type, including before-save, after-save, and scheduled paths. The list is shown in run order, and you can adjust the order there too.
Use it at three moments:
- Before consolidating, to see what already exists.
- After building a flow, to confirm where it sits among the others.
- During cutover, to confirm that only the intended flows are active.
A worked consolidation plan
Suppose the Opportunity inventory shows these items:
Workflow Rule Opp_Set_Close_Date_Default (field update)
Workflow Rule Opp_Notify_Owner_Big_Deal (email alert, Amount > 100000)
Process Opp_Closed_Won_Process (create Task, update Account field, 7-day scheduled email)
Process Opp_Stage_Change_Chatter (post to Chatter)A consolidated design with explicit order:
Before-save, order 100:
Opp_BeforeSave_Defaults
- Assignment: set CloseDate default when blank
(replaces Opp_Set_Close_Date_Default)
After-save, order 100:
Opp_AfterSave_ClosedWon
- Decision: Became Closed Won
- Create Records: follow-up Task
- Update Records: Account field
- Scheduled path, 7 days after CloseDate: Send Email
(replaces Opp_Closed_Won_Process)
After-save, order 200:
Opp_AfterSave_Notifications
- Decision: Amount > 100000 (became true) -> Send Email
- Decision: Stage changed -> Post to Chatter
(replaces Opp_Notify_Owner_Big_Deal and Opp_Stage_Change_Chatter)The default-date rule moves to a before-save flow because it only changes the triggering record, which is cheaper than an after-save update. The two notification items merge because neither depends on the other. The Closed Won flow stays separate so it can be tested on its own.
Common errors
- Merging without prior-value checks. Notifications start repeating on every edit.
- Assuming trigger order covers Apex. Existing triggers still run at their fixed points.
- Leaving old automation active. The Workflow Rule and the new flow both fire, so users get duplicate emails or Tasks.
- Two flows updating the same record. A second after-save flow that updates the triggering record can cause extra DML and re-fire other automation. Move same-record updates into a before-save flow where possible.
Exercise
An Opportunity has an after-save flow "Create Task" and another after-save flow "Update Account Status". Update Account Status needs to read the Task created by the first flow. What should you do, and what can you not do?
Show answer
Set Trigger Order values on both flows, for example 100 on Create Task and 200 on Update Account Status, so the Task exists first. Better still, if the logic is closely tied, put both actions in one flow in sequence. You cannot use Trigger Order to run either flow before a before-save flow or an Apex before trigger, because order values only sort flows of the same object and the same timing.