Sub topic 10
Planning a migration from legacy automation to Flow
This chapter assumes you know the basics of Flow Builder, record-triggered flows, and the order of execution. You should also have read the previous chapter on why Workflow Rules and Process Builder are legacy. Here the focus is on planning: how to inventory what exists, decide what to build, move it safely, and avoid the errors that cause regressions.
Why a plan matters
Salesforce no longer enhances Workflow Rules or Process Builder, and it has announced end of support for both. Existing automation keeps running until then, but you cannot create new Workflow Rules or processes in orgs where the feature is retired, and Salesforce will not fix new issues. Check the current Salesforce release notes for the exact dates that apply to your org.
A migration is not a copy and paste job. Legacy tools differ from Flow in execution order, in how they handle bulk records, and in how they re-evaluate criteria. A faithful one-to-one conversion can change behavior in ways that no one notices until a field holds the wrong value in production.
Step 1: Inventory what exists
Start by listing every piece of legacy automation, per object. Useful sources:
- Setup, Workflow Rules and Process Automation Settings, and the Process Builder list for active processes.
- The Migrate to Flow tool in Setup, which lists Workflow Rules and processes and can convert some of them.
- The Metadata API or Salesforce CLI, which let you retrieve
WorkflowRuleandFlowmetadata for review in source control.
For each item, record the object, the trigger (create, update, or both), the criteria, the actions, whether it is active, and who owns it. Also record whether it still has a business purpose. Many orgs contain automation for processes that ended years ago. Retiring dead automation is cheaper than migrating it.
Step 2: Map actions to Flow equivalents
Most legacy actions have a direct Flow counterpart. Some need a different design.
| Legacy action | Flow equivalent | Notes |
|---|---|---|
| Workflow field update on the same record | Before-save record-triggered flow, Assignment element | Faster than an after-save flow because it needs no extra DML. |
| Workflow email alert | Action element that calls an email alert, or Send Email | Existing email alerts can be reused. |
| Workflow task creation | Create Records element on Task | Runs after save. |
| Workflow outbound message | Outbound message action, or an HTTP callout in Flow | Needs review. Check the endpoint and retry behavior. |
| Workflow time-based action | Scheduled path in a record-triggered flow | Behavior differs. See the edge cases below. |
| Process Builder criteria node | Decision element, or entry conditions | Move simple filters into entry conditions. |
| Process Builder invoking Apex | Apex action in Flow | The Apex method needs the `@InvocableMethod` annotation. |
| Process Builder updating related records | Update Records element after save | Watch for recursion on the related object. |
Step 3: Decide how to consolidate
Process Builder encouraged one process per object with many criteria nodes, while Workflow encouraged one rule per action. Neither pattern suits Flow well. A common guideline is one record-triggered flow per object per trigger timing (before-save, after-save), with entry conditions that keep each flow small. Another approach is one flow per business capability, such as lead routing or opportunity close tasks.
Pick one convention and document it. The trade-off:
- Fewer, larger flows are easier to reason about for execution order but harder to edit safely.
- Many small flows are easier to test and own, but Salesforce does not guarantee order between flows unless you set a trigger order on each flow.
If order matters between two flows on the same object, set the Trigger Order value in the flow's Run Flows in Order setting. Do not rely on alphabetical or creation order.
Step 4: Watch for behavioral differences
These cause most migration bugs.
- Execution timing. Workflow field updates ran after before-triggers and validation rules, and could re-fire before-triggers and after-triggers once. Before-save flows run earlier, before most validation. A flow that reads a field set by a before trigger may see a different value than the Workflow did.
- Re-evaluation criteria. Workflow rules had options such as "only when created" or "every time a record is created or edited." Process Builder offered "only when specified changes are made to the record." In Flow, set the entry condition and choose "Only when a record is updated to meet the condition requirements" to avoid running on every save.
- Time-based actions. Workflow queued time-based actions and removed them if the record stopped meeting criteria. Flow scheduled paths are similar, but they work differently when conditions change after scheduling. Test this case explicitly.
- Recursion. An after-save flow that updates the same record starts the save process again. Avoid this by using a before-save flow for same-record changes.
- Bulk volume. Process Builder processed records in batches. Flows are bulkified, but a loop that contains a Get Records or Update Records element can still hit governor limits. Put data elements outside loops.
Step 5: Convert, then verify
The Migrate to Flow tool can convert eligible Workflow Rules and Process Builder processes. It supports a subset of actions, so treat its output as a draft. Review each generated flow, rename it to follow your naming convention, and add a description.
A suggested sequence for each object:
- Build or convert the flow in a sandbox. Leave it inactive.
- Write test cases from the legacy behavior: each criteria path, each action, and the "does not fire" cases.
- Deactivate the legacy automation and activate the flow in the same deployment, so that both never run at once.
- Run the test cases, plus any Apex tests that insert or update the object.
- Monitor after release and keep the legacy metadata available for rollback.
The most important rule is to avoid overlap. If a Workflow rule and its replacement flow are both active, the action runs twice, which can duplicate tasks and emails.
An example: before and after
A Workflow Rule sets Rating to Hot when AnnualRevenue is at least 1,000,000. The Flow replacement is a before-save record-triggered flow on Account with the entry condition AnnualRevenue >= 1000000 and one Assignment element setting Rating to Hot. It needs no Update Records element, because a before-save flow changes the record being saved.
If the requirement is more complex than a flow can handle, such as logic that depends on many related records at high volume, the same behavior can be written in Apex:
trigger AccountTrigger on Account (before insert, before update) {
for (Account acc : Trigger.new) {
if (acc.AnnualRevenue != null && acc.AnnualRevenue >= 1000000) {
acc.Rating = 'Hot';
}
}
}For this requirement, the flow is the better choice. Use the trigger only if a clear reason exists, since it adds code to test and maintain.
Rollout flow
Common errors
- Running both the old and new automation at the same time.
- Converting every Process Builder criteria node to a Decision element and ending up with a flow too large to maintain.
- Using after-save flows for same-record field updates, which costs extra DML and risks recursion.
- Skipping tests for the "does not fire" paths, so the flow runs more often than the legacy rule did.
- Ignoring Apex tests. Existing tests that insert records may now trigger flows and fail on required fields or validation rules.
Exercise
A Workflow Rule updates a field on the same Account whenever the record is saved with a Type of "Customer". You convert it to an after-save record-triggered flow with an Update Records element. What problem does this introduce, and what is the better design?
Show answer
An after-save flow that updates the record being saved needs an extra DML operation and causes the record to go through the save process again, which risks recursion and uses more limits. The better design is a before-save record-triggered flow with an Assignment element, which changes the record in memory before it is saved. Set the entry condition to Type equals Customer.
Exercise
Two record-triggered flows on Opportunity both run after save, and the second one depends on a field the first one sets. What should you do?
Show answer
Do not rely on the default order. Set the Trigger Order on each flow so the first one runs earlier. Alternatively, combine the dependent logic into one flow so that the order is explicit.