Flow Deployment & Activation Ordering
Purpose
Flow deployments are deceptively tricky. Unlike Apex, Flow preserves
previous versions in the org; the "active" version is a pointer. A deploy
can inadvertently deactivate the currently-running flow, leave two flows
active in sequence, or break paused interviews that refer to the old
version. The team hits production incidents: "the approval flow stopped
triggering," "paused interviews threw after deploy," "rollback just
deactivated everything." This skill codifies the sequence, guards, and
verification to make Flow deploys boring.
Recommended Workflow
- Inventory changes. Which flows changed? Which have paused
interviews or scheduled runs currently in progress?
- Check active versions in target org.
sf data query against
FlowDefinition and Flow to confirm what is active today.
- Pick activation mode. Deploy as active (default) vs deploy as
inactive then activate via
FlowDefinition update. Inactive-first is
safer for risky flows.
- Plan the order. If Flow A calls Subflow B, deploy B first (active
before A switches).
- Communicate pause windows. If paused interviews exist on the
changing flow, delay deploy or accept that paused interviews may fail
on resume.
- Deploy, verify, and plan rollback. Use
--test-level RunSpecifiedTests --tests <ClassName> [...] when Apex callers exist (Flow itself has no test framework parity). --tests is what names the classes to run — RunSpecifiedTests on its own specifies nothing — and this level changes the coverage rule: "Each class and trigger in the deployment package must be covered by the executed tests for a minimum of 75% code coverage." Re-query active versions post-deploy; run a smoke Flow interview; check for spikes in Flow error emails. Keep the prior active version id captured before deploy — rollback = flip the pointer on FlowDefinition, not redeploy.
The Asymmetry Everything Turns On
Deploying a flow always creates a new version. It never restores an old one.
Activation, by contrast, is a pointer into versions that already exist in the
org. Deploy and activate are different operations with different rollback
properties, and conflating them causes most incidents in this domain.
Active vs Draft Deploy
- Deploy a pending version with
<status>Draft</status>, verify it, then
activate as a separate step. Obsolete is what the platform assigns to a
superseded version — it is never the right thing to choose for a new one. The
status field has five valid values: Active, Draft, Obsolete,
InvalidDraft, and UnderReview. They do not map one-to-one onto the UI
labels — Draft and Obsolete both display as Inactive, InvalidDraft
displays as Draft, and UnderReview displays as Under Review — so never
infer the API value from what Setup shows you.
- Prefer
<status>Active</status> on the Flow for routine deploys.
- Keep
FlowDefinition out of routine packages. This recommendation is
routinely misremembered as "upgrade flows to API version 44.0". What Salesforce
actually says is: "In API version 44.0, we recommend upgrading your flows to
flow metadata file names without version numbers and discontinue using the
FlowDefinition object to activate or deactivate a flow." That is a
recommendation made in 44.0, about file naming and about dropping
FlowDefinition — not an instruction to move flows to API version 44.0. The
precedence rule is the trap: "the active version numbers in the flow definitions
override the status fields in the flows." A stale FlowDefinition silently wins
over every status in the package.
- One production-only constraint: the Deploy processes and flows as active
preference (Setup → Process Automation Settings) and its flow test coverage
percentage do not exist in developer or sandbox orgs. A green sandbox deploy is
not evidence the production deploy will pass. The coverage requirement applies
to processes and autolaunched flows and does not apply to flows that have
screens.
Paused Interview Risk
Paused interviews resume on the version they started on. The deploy is safe — the
old version stays in the org. The cleanup is what breaks them, usually weeks
later in an unrelated change, which is why nobody connects the failure back.
- Snapshot
FlowInterview before deploying. InterviewLabel embeds the flow's
API name and version number, which is how you check "does anything still
reference version 7?"
- Gate deletion on zero interview references, never on age.
- Since Spring '24 there is no platform cap on how many paused and waiting
interviews an org accumulates, so this population grows quietly and will not
self-limit.
- Screen flows with Pause elements are the most common victims.
Subflow / Activation-Order Rules
Subflow resolution is late: the parent runs whatever version of the child is
active at interview time, and the latest version if the child has none active.
- Deploy both as
Draft, verify the child, activate the child, then activate
the caller. Between those two activations the old caller runs against the
new child, which is the compatible direction.
- Ordering inside a single deploy changes nothing — the deploy is atomic. It is
the activation order that matters.
- Activation is not atomic across two flows. For a breaking child change no
ordering helps; that needs a new child flow with a caller repoint, which is
flow/flow-versioning-strategy's call.
- Deactivating a child does not stop callers. It drops them onto the latest
version, possibly an untested draft.
Rollback Pattern
- Capture the active version number per flow per environment before the
deploy. That capture is the entire rollback plan, and the repository does not
contain it — activation is org state.
- Roll back by activating the version that already exists: one click on the
flow's detail page, or a standalone
FlowDefinition deployment with
activeVersionNumber set to the version you want live. This is the one case
where FlowDefinition earns its place, because pointing at an existing version
number is the thing status cannot express. To take a flow off rather than
move the pointer, deactivate on the flow's detail page or deploy the version
with <status>Draft</status> — both are documented behaviours.
- Do not delete the bad version. It is the evidence and it preserves the
forward-fix path.
- Rollback stops future damage and repairs nothing past. Records already written
stay wrong, published platform events are gone and their subscribers already
acted, and enqueued scheduled paths are still queued. Write the data-remediation
plan alongside the deploy plan.
CI/CD
- Pre-deploy: capture
FlowDefinitionView (standard API — ActiveVersionId,
LatestVersionId, IsActive) plus a Tooling API query against Flow for
version numbers, plus a FlowInterview snapshot. Flow is a Tooling API
object; a standard-API query returns "sObject type 'Flow' is not supported" and
a careless script degrades to checking nothing.
- Post-deploy: re-query
FlowDefinitionView and diff. An unexplained row is a
finding — a managed package upgrade can move a flow's active version without
appearing in your release notes.
- Then the checks a script cannot make: run one real interview of each changed
flow through its actual entry point, watch flow error email volume for a step
change, and check Setup → Environments → Monitoring → Time-Based Workflow
for scheduled and async entries that should have drained.
Anti-Patterns (see references/llm-anti-patterns.md)
- Rolling back by redeploying prior source — creates a new version, does not
restore the old one.
<status>Obsolete</status> used to mean "inactive".
- Bundling
FlowDefinition with Flow "for certainty" — it silently overrides.
- Inventing
FlowDefinition.ActiveVersion; the field is activeVersionNumber.
- Querying
Flow without --use-tooling-api.
- Treating deactivation as a kill switch.
- Ending the runbook at "the deploy succeeded."
- Assuming rollback undoes the data.
Related
flow/flow-versioning-strategy — new version vs new flow, and the retention
rule this skill enforces at deploy time.
flow/flow-deployment-and-packaging — change sets vs SFDX vs packages.
devops/devops-center-advanced — promoting flows through a work-item pipeline.
devops/deployment-error-diagnosis — reading a failed deploy.
flow/flow-interview-debugging — why the version in an error email is usually
not the active one.
Official Sources Used
The full annotated list is in references/well-architected.md.
1---2name: flow-deployment-activation-ordering3description: Deploying Flow metadata across environments when activation order matters: which flow version becomes active, how paused interviews survive deploys, avoiding the 'two active versions for a moment' race, SFDX / Metadata API deploy flags, 'Deploy as Active', rollback. NOT for Change Set vs SFDX vs package choice for a flow — use flow/flow-deployment-and-packaging. NOT for whether a change needs a new version or a new flow — use flow/flow-versioning-strategy.4---56# Flow Deployment & Activation Ordering78## Purpose910Flow deployments are deceptively tricky. Unlike Apex, Flow preserves11previous versions in the org; the "active" version is a pointer. A deploy12can inadvertently deactivate the currently-running flow, leave two flows13active in sequence, or break paused interviews that refer to the old14version. The team hits production incidents: "the approval flow stopped15triggering," "paused interviews threw after deploy," "rollback just16deactivated everything." This skill codifies the sequence, guards, and17verification to make Flow deploys boring.1819## Recommended Workflow20211. **Inventory changes.** Which flows changed? Which have paused22 interviews or scheduled runs currently in progress?232. **Check active versions in target org.** `sf data query` against24 `FlowDefinition` and `Flow` to confirm what is active today.253. **Pick activation mode.** Deploy as active (default) vs deploy as26 inactive then activate via `FlowDefinition` update. Inactive-first is27 safer for risky flows.284. **Plan the order.** If Flow A calls Subflow B, deploy B first (active29 before A switches).305. **Communicate pause windows.** If paused interviews exist on the31 changing flow, delay deploy or accept that paused interviews may fail32 on resume.336. **Deploy, verify, and plan rollback.** Use `--test-level RunSpecifiedTests --tests <ClassName> [...]` when Apex callers exist (Flow itself has no test framework parity). `--tests` is what names the classes to run — `RunSpecifiedTests` on its own specifies nothing — and this level changes the coverage rule: "Each class and trigger in the deployment package must be covered by the executed tests for a minimum of 75% code coverage." Re-query active versions post-deploy; run a smoke Flow interview; check for spikes in Flow error emails. Keep the prior active version id captured before deploy — rollback = flip the pointer on `FlowDefinition`, not redeploy.3435## The Asymmetry Everything Turns On3637**Deploying a flow always creates a new version. It never restores an old one.**38Activation, by contrast, is a pointer into versions that already exist in the39org. Deploy and activate are different operations with different rollback40properties, and conflating them causes most incidents in this domain.4142## Active vs Draft Deploy4344- Deploy a pending version with `<status>Draft</status>`, verify it, then45 activate as a separate step. `Obsolete` is what the platform assigns to a46 superseded version — it is never the right thing to choose for a new one. The47 `status` field has **five** valid values: `Active`, `Draft`, `Obsolete`,48 `InvalidDraft`, and `UnderReview`. They do not map one-to-one onto the UI49 labels — `Draft` and `Obsolete` both display as *Inactive*, `InvalidDraft`50 displays as *Draft*, and `UnderReview` displays as *Under Review* — so never51 infer the API value from what Setup shows you.52- Prefer `<status>Active</status>` on the `Flow` for routine deploys.53- Keep `FlowDefinition` **out** of routine packages. This recommendation is54 routinely misremembered as "upgrade flows to API version 44.0". What Salesforce55 actually says is: "In API version 44.0, we recommend upgrading your flows to56 flow metadata file names without version numbers and discontinue using the57 FlowDefinition object to activate or deactivate a flow." That is a58 recommendation made *in* 44.0, about file naming and about dropping59 `FlowDefinition` — not an instruction to move flows *to* API version 44.0. The60 precedence rule is the trap: "the active version numbers in the flow definitions61 override the status fields in the flows." A stale `FlowDefinition` silently wins62 over every `status` in the package.63- One production-only constraint: the **Deploy processes and flows as active**64 preference (Setup → Process Automation Settings) and its flow test coverage65 percentage do not exist in developer or sandbox orgs. A green sandbox deploy is66 not evidence the production deploy will pass. The coverage requirement applies67 to processes and autolaunched flows and does **not** apply to flows that have68 screens.6970## Paused Interview Risk7172Paused interviews resume on the version they started on. The deploy is safe — the73old version stays in the org. The **cleanup** is what breaks them, usually weeks74later in an unrelated change, which is why nobody connects the failure back.7576- Snapshot `FlowInterview` before deploying. `InterviewLabel` embeds the flow's77 API name and version number, which is how you check "does anything still78 reference version 7?"79- Gate deletion on zero interview references, never on age.80- Since Spring '24 there is no platform cap on how many paused and waiting81 interviews an org accumulates, so this population grows quietly and will not82 self-limit.83- Screen flows with Pause elements are the most common victims.8485## Subflow / Activation-Order Rules8687Subflow resolution is late: the parent runs whatever version of the child is88active at interview time, and the *latest* version if the child has none active.8990- Deploy both as `Draft`, verify the child, activate the **child**, then activate91 the **caller**. Between those two activations the old caller runs against the92 new child, which is the compatible direction.93- Ordering inside a single deploy changes nothing — the deploy is atomic. It is94 the *activation* order that matters.95- Activation is not atomic across two flows. For a breaking child change no96 ordering helps; that needs a new child flow with a caller repoint, which is97 `flow/flow-versioning-strategy`'s call.98- Deactivating a child does **not** stop callers. It drops them onto the latest99 version, possibly an untested draft.100101## Rollback Pattern102103- Capture the active version number per flow per environment **before** the104 deploy. That capture is the entire rollback plan, and the repository does not105 contain it — activation is org state.106- Roll back by activating the version that already exists: one click on the107 flow's detail page, or a standalone `FlowDefinition` deployment with108 `activeVersionNumber` set to the version you want live. This is the one case109 where `FlowDefinition` earns its place, because pointing at an existing version110 number is the thing `status` cannot express. To take a flow *off* rather than111 move the pointer, deactivate on the flow's detail page or deploy the version112 with `<status>Draft</status>` — both are documented behaviours.113 <!-- UNVERIFIED: `activeVersionNumber` = 0 is widely reported to deactivate a114 flow, but meta_flowdefinition.htm documents the field only as "The version115 number of the active flow" and states no behaviour for 0. Nothing in this116 runbook depends on it; if you want to use it, confirm in a sandbox first. -->117- Do **not** delete the bad version. It is the evidence and it preserves the118 forward-fix path.119- Rollback stops future damage and repairs nothing past. Records already written120 stay wrong, published platform events are gone and their subscribers already121 acted, and enqueued scheduled paths are still queued. Write the data-remediation122 plan alongside the deploy plan.123124## CI/CD125126- **Pre-deploy:** capture `FlowDefinitionView` (standard API — `ActiveVersionId`,127 `LatestVersionId`, `IsActive`) plus a Tooling API query against `Flow` for128 version *numbers*, plus a `FlowInterview` snapshot. `Flow` is a Tooling API129 object; a standard-API query returns "sObject type 'Flow' is not supported" and130 a careless script degrades to checking nothing.131- **Post-deploy:** re-query `FlowDefinitionView` and diff. An unexplained row is a132 finding — a managed package upgrade can move a flow's active version without133 appearing in your release notes.134- **Then the checks a script cannot make:** run one real interview of each changed135 flow through its actual entry point, watch flow error email volume for a step136 change, and check Setup → Environments → Monitoring → **Time-Based Workflow**137 for scheduled and async entries that should have drained.138139## Anti-Patterns (see `references/llm-anti-patterns.md`)140141- Rolling back by redeploying prior source — creates a new version, does not142 restore the old one.143- `<status>Obsolete</status>` used to mean "inactive".144- Bundling `FlowDefinition` with `Flow` "for certainty" — it silently overrides.145- Inventing `FlowDefinition.ActiveVersion`; the field is `activeVersionNumber`.146- Querying `Flow` without `--use-tooling-api`.147- Treating deactivation as a kill switch.148- Ending the runbook at "the deploy succeeded."149- Assuming rollback undoes the data.150151## Related152153- `flow/flow-versioning-strategy` — new version vs new flow, and the retention154 rule this skill enforces at deploy time.155- `flow/flow-deployment-and-packaging` — change sets vs SFDX vs packages.156- `devops/devops-center-advanced` — promoting flows through a work-item pipeline.157- `devops/deployment-error-diagnosis` — reading a failed deploy.158- `flow/flow-interview-debugging` — why the version in an error email is usually159 not the active one.160161## Official Sources Used162163- FlowDefinition (Metadata API) — https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_flowdefinition.htm164- Flow (Metadata API) — https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_visual_workflow.htm165- Flow (Tooling API) — https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/tooling_api_objects_flow.htm166- FlowDefinitionView (Object Reference) — https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_flowdefinitionview.htm167- Deploy Processes and Flows as Active — https://help.salesforce.com/s/articleView?id=platform.flow_distribute_deploy_active.htm&type=5168- Salesforce CLI Command Reference, `sf project deploy` — https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_project_commands_unified.htm169170The full annotated list is in `references/well-architected.md`.