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.
When To Use
- Planning a release that changes any Record-Triggered, Screen, or Scheduled Flow.
- Debugging paused interview failures after a deploy.
- Writing a Flow rollback runbook.
- Standardizing Flow CI/CD.
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 queryagainstFlowDefinitionandFlowto confirm what is active today. - Pick activation mode. Deploy as active (default) vs deploy as
inactive then activate via
FlowDefinitionupdate. 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. Use
--test-level RunSpecifiedTestswhen Apex callers exist; Flow itself has no test framework parity. - Verify. Re-query active versions post-deploy; run a smoke Flow interview; check for spikes in Flow error emails.
- Rollback plan. Keep prior active version id; rollback = flip
pointer on
FlowDefinition, not redeploy.
Active vs Inactive Deploy
- Default SFDX behavior: deploys a new flow VERSION; activation depends on flags.
--ignore-warningscan mask inactive deploys silently activating.- For risky flows, explicitly deploy as inactive, then flip activation in a separate step once verified.
Paused Interview Risk
Paused interviews reference a specific version. If that version is deactivated or deleted, resume fails. Mitigations:
- Do not delete prior versions for N days (retain for paused interview survival).
- For large deploys, drain paused interviews first (resume or cancel via Setup).
- Screen Flows with wait elements are the most common victims.
Subflow / Calling-Order Rules
- Deploy callee subflow FIRST, then caller.
- If both change together, deploy as inactive, activate callee, then activate caller.
- Cross-package dependencies (packaged subflow + unmanaged caller) need extra care.
Rollback Pattern
- Keep the prior version active-id BEFORE deploy.
- Rollback =
FlowDefinition.ActiveVersionpointer update, via Metadata API or Tooling API. - Do NOT delete the new version during rollback; keeping it makes forward-fix possible.
CI/CD
- Source-tracked orgs: every deploy includes the flow source as xml.
- Pre-deploy hook: capture active version ids (for rollback).
- Post-deploy hook: verify expected active version became active.
- Scratch-org test: run any Apex invokers that call the flow.
Anti-Patterns (see references/llm-anti-patterns.md)
- "Deploy and pray" — no pre-deploy inventory.
- Deleting old flow versions as cleanup.
- Rolling back by redeploying the prior source (creates a new version, not the prior version).
- Deploying caller + callee subflow in random order.
Official Sources Used
- Flow Metadata API — https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_flow.htm
- SFDX Deploy Reference — https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_sf_project.htm
- Flow Versioning — https://help.salesforce.com/s/articleView?id=sf.flow_distribute_deploy.htm
- Paused Interviews — https://help.salesforce.com/s/articleView?id=sf.flow_admin_paused.htm