Why New Salesforce Flow Versions Appear on Deployment (and How to Fix It)
Ever stared at a deployment result in disbelief? You know you didn’t change that specific Flow – maybe you haven’t touched it in months – yet Salesforce insists on creating a brand new version. Even worse, this phantom version pushed you over the dreaded 50-version limit, causing your entire deployment to fail. Frustrating, right?
If this sounds familiar, you’re not alone. There’s often a subtle reason behind this behavior, hidden within the Flow’s metadata.
The Underlying Cause: Invisible Metadata Drift
Salesforce often creates a new flow version during deployments, even when there are no visible changes in the flow’s XML. This issue typically arises due to minor differences between the source and target environments, such as deprecated or auto-generated properties in the flow metadata.
Steps to Identify and Resolve the Issue:
- Set Up a Clean Branch: Ensure your Git branch has no unstaged changes.
-
Deploy the Problematic Flow: Use the following command to deploy the flow to a sandbox:
> sf project deploy start --metadata Flow:MyProblematicFlow –-target-org MySandbox
Observe that the deployment result indicates a “Changed” status, and a new version is created.
-
Retrieve the Flow from the Sandbox: Run the following command to pull the flow from the sandbox:
> sf project retrieve start --metadata Flow:MyProblematicFlow --target-org MySandbox
Check the retrieved XML for differences compared to your local version.
-
Analyze the Differences: Look for minor discrepancies, such as:
- Deprecated properties (e.g.,
<migratedFromWorkflowRuleName>
). - Auto-generated metadata (e.g., locationX, locationY, or processMetadataValues).
- Deprecated properties (e.g.,
- Re-deploy the Retrieved Version: Deploy the retrieved version back to the sandbox. If the deployment result now shows “Unchanged,” the issue is resolved.
By following this retrieve-analyze-commit-redeploy process, you effectively synchronize your source control version of the Flow with the subtle metadata nuances expected by Salesforce in your target environments. This stops the frustrating creation of unnecessary Flow versions, helps you stay comfortably below the 50-version limit, and leads to smoother, more predictable deployments.