Why does my flow fail to deploy?
Almost always because it points at something the target org does not have. The exact text for each case:
- A subflow that is not there:
Call_Router (Subflow) - The flow Legacy_Router doesn't exist. - An Apex action that is not deployed:
Do_Apex (Action) - We can't find the InvoiceSyncAction action. Verify that it's available and that you have the permissions and licenses required to use it. - An object that does not exist:
field integrity exception: unknown (The Site_Visit__c object doesn't exist. Enter a valid object.) - A flow with nothing wired to Start:
field integrity exception: unknown (The flow can't run because nothing is connected to the Start element.)
The version status does not change the message. A missing subflow fails whether the flow is Draft or Active, so you cannot dodge a dependency by deploying the flow as a draft.
Why did the flow deploy but stay inactive?
By default, active processes and flows are deployed as inactive. In a production org you can switch on a setting so a new active version goes live on deploy, and with it on, the deploy fails if the flow does not meet the coverage requirement; Salesforce's wording is quoted on Salto's help page. The setting is called Deploy processes and flows as active, and it lives in Setup, under Process Automation Settings.
Change sets add a second rule. You can include only one version of a flow, an active flow goes to the destination as inactive, and the upload creates a new version there (Salesforce Help).
How do I fix a flow deploy error in Setup?
- Read the component line in Setup > Deployment Status > View Details. Note the element name in front of the brackets, such as
Call_Router. It is the flow element that holds the bad reference. - Open the flow in the source org and click that element. Look at what it points to.
- Make sure the target has that thing. For a subflow, deploy the subflow first, or in the same package. For an Apex action, deploy the class that carries the
@InvocableMethod. For an object or field, deploy it before the flow. - Validate again.
- After the real deploy, open Setup, Flows, find the flow, and check which version is Active. If the newest version is not, open it and click Activate.
How do I fix it with the CLI?
Put the flow and what it calls in one deploy, then check it:
sf project deploy start --source-dir force-app/main/default/flows --source-dir force-app/main/default/classes --dry-run --test-level NoTestRun -o target-org
If the real deploy lands inactive, activate by hand in Setup, or turn the production setting on once and deal with the coverage rule on purpose.
How do I keep flow deploys clean?
Deploy in dependency order: objects and fields, then Apex, then subflows, then the parent flow. Keep a short note of the flow's active version number before a release. When a flow misbehaves after deploy, flow debugging is the next place to look, and the flow glossary entry explains the types. AI Salesforce deployments checks the order of a bundle for you before you approve it.
Questions about flow deploy errors
Why is my deployed flow inactive in production?
Salesforce deploys active flows as inactive by default. Turn on Deploy processes and flows as active in production, or activate the new version by hand after the deploy.
Can I deploy a flow that calls Apex that is not in production yet?
No. The Apex class has to be in the target first or in the same package. Otherwise you get the message that Salesforce can't find the action.
Does a change set carry all versions of a flow?
No. Only one version goes in a change set, and an active flow arrives inactive.
How do I roll back a bad flow version?
Open the flow in Setup, Flows, and activate the earlier version. Old versions stay on the list until you delete them.