海角天涯社区

How Flows and Flow Definitions changed with the Salesforce Metadata API v44

How Flows and Flow Definitions changed with the Salesforce Metadata API v44

David Runciman on

Share with



Flows are every admin鈥檚 friend until it gets to deployment time. Whether it鈥檚 a missing dependency or an error message that leaves you scratching your head, Flows can make deployments fail more often than other metadata types.

To make things a little bit more complicated, deploying Flows via the Metadata API has also changed over the years. This post covers that story and explains how to overcome a raft of Flow deployment errors you might be battling with:

  • Insufficient access rights on cross-reference id
  • You can鈥檛 create a flow definition directly through the API
  • Invalid version number: <insert version number>
  • The version of the flow you鈥檙e updating is active and can鈥檛 be overwritten

How did Flows change with v44 of the Metadata API?

Salesforce made changes to the way Flow metadata works in its Winter 鈥�19 release (v44 of the Metadata API). Previously, Flow versions had been managed using filenames, and Flow Definitions were critical bits of metadata because they defined which Flow was the active version. In 2019, Salesforce recognized that this approach was at odds with using version control, so it transformed Flows 鈥� making Flow deployments quite different in the process.

Let鈥檚 take a look at the two main changes and their implications for how to deploy Flow versions in Salesforce.

1. Flow version numbers are no longer in the Flow name

Saving a set of changes in Flow Builder always creates a new version of the Flow, so you have to think about Flow versions during deployments. Before v44 of the Metadata API, version numbers were part of the Flow name, e.g. MyFlow-<version-number>.flow. From v44 onwards, version numbers have been stripped out, e.g. MyFlow.flow.

This change means that you can now only retrieve and deploy the latest version of your Flow from Salesforce via Metadata API, if you use v44 or later. When you deploy that Flow, it will be created in the target as a new version 鈥� and the version number may not match the version in the source.

Prior to v44, if you tried to deploy a change to an active or obsolete flow, you鈥檇 get a deployment error. From v44 onwards, Salesforce will simply create a new version of the Flow in the target.

2. Salesforce encourages you not to use Flow Definitions

Instead of relying on Flow Definitions to define which version of a Flow is active, from v44 onwards Flows have a status field which determines whether a Flow is active, inactive, or a draft. When you deploy a Flow, it will generally be given the inactive status, although you can in Salesforce and deploy Flows as active.

Flow Definitions haven鈥檛 been retired 鈥� you can still retrieve and deploy them via any version of the Metadata API. And it鈥檚 still possible to use a Flow Definition to switch which Flow is active. But care is needed, because Flow version numbers between orgs are no longer linked. A Flow Definition might even end up pointing at a version that doesn鈥檛 exist in your target org!

Salesforce DevOps in the age of AI: is your custom pipeline ready?

Find out more

Are Flow Definitions still needed?

It鈥檚 definitely a good idea to move on from Flow Definitions, especially if you鈥檝e adopted version control.

There are possible use cases for Flow Definitions. For example, imagine you鈥檝e begun working on a Flow, and so you鈥檝e got a new latest version as a draft, but then you want to deploy the active version of the Flow. Using v44 onwards, Salesforce will only retrieve the latest version of the Flow. If you need to deploy a version of a Flow that isn鈥檛 the latest version, you can use v43 of the Metadata API and specify the active Flow with a Flow Definition. Of course, any post-v44 features of your Flows may not be deployable that way.

It鈥檚 also worth noting that you need to retrieve Flow Definitions in order to deploy Flow Access permissions metadata.

How to graduate from Flow Definitions to v44

Salesforce鈥檚 Metadata API guide has for upgrading Flows to v44. With 海角天涯社区, the process is even simpler: just compare your org and Git branch using v44 of the API or higher. All versioned Flows will be marked as 鈥榙eleted鈥�, leaving one unversioned Flow marked as 鈥榗hanged鈥� or 鈥榥ew鈥�. Select all of these changes and commit them to your branch.

Flow deployment errors 鈥� and how 海角天涯社区 solves them

Even when you鈥檝e got your head around all of the changes made by v44 of the Metadata API, Flows are still a common cause of deployment errors. 海角天涯社区 has almost 100 problem analyzers that highlight anything in your deployment packages that鈥檚 likely to make it fail 鈥� and in most cases it鈥檚 able to fix the issue for you. For example, any missing dependencies (and those are easy to forget with Flows in particular!) are flagged by a problem analyzer, and 海角天涯社区 will offer to include the missed items for you.

Since there are various ways Flow deployments can fail, 海角天涯社区 also has a number of problem analyzers specifically for Flows and Flow Definitions.

Warning when deploying Flow Definitions after v44

Because deploying Flow Definitions on v44 or higher of the Metadata API can be problematic, one of 海角天涯社区鈥檚 problem analyzers will about a deployment package that does this. You can decide whether or not to remove the Flow Definition.

海角天涯社区 warns you when deploying a Flow Definition post v44 of the MDAPI

鈥業nsufficient access rights on cross-reference id鈥�

This is a fairly general-purpose Salesforce error message that can crop up in a few different ways during a Flow deployment.

Post-v44, if you鈥檙e trying to deploy a deleted Flow, all versions of that Flow in the target must be identified for deletion. But as the API no longer returns versions of Flows, this isn鈥檛 normally possible over the Metadata API. seeing the Problem: setup object in use error when attempting destructive changes. 海角天涯社区 by identifying all the versions in the target that need to be deleted, and adding those into your deployment package for you.

海角天涯社区 helps you delete all versions of a Flow

If you鈥檙e using pre-v44 of the API, the error Insufficient access rights on cross-reference id can be triggered when you鈥檝e deleted a , and are trying to deploy that destructive change. 海角天涯社区 will automatically recommend removing these destructive changes from your deployment package.

海角天涯社区 removes deleted Flow Definitions from your package 鈥� they will cause your deployment to fail

鈥榊ou can鈥檛 create a Flow Definition directly through the Metadata API. A Flow Definition is created automatically when you create a new Flow version鈥�

This Salesforce error message seems self-explanatory, but can be misleading. It鈥檚 true that you鈥檙e unable to deploy a new Flow Definition on its own directly through the API, but you can if you鈥檙e deploying any version of the corresponding Flow along with it. 海角天涯社区 detects any lone Flow Definitions and suggests you either add the relevant Flow or remove the Flow Definition from the deployment.

海角天涯社区 suggests fixes when you try to deploy a Flow Definition without its Flow

鈥業nvalid version number: [insert version number]鈥�

This error is specific to deploying via pre-v44 API. You can鈥檛 deploy a Flow Definition referencing a version of a Flow that won鈥檛 be present in the target after the deployment. If 海角天涯社区 detects that you鈥檙e missing a referenced Flow, it鈥檒l offer to add the missing version to the deployment package.

海角天涯社区 can include Flows to your package that are missing in the target

鈥楾he version of the Flow you鈥檙e updating is active and can鈥檛 be overwritten鈥�

This is another pre-v44 error, triggered when an active or obsolete Flow in the target has been changed in the source. In theory this should be unlikely, but it鈥檚 surprisingly easy to end up with a Flow that has existed in a different state on both source and target, and then been activated on both independently with the appearance of being the same version. Using a more recent version of the API, Salesforce will add the Flow as a new version anyway, which resolves the issue.

Go with the Flow

Flows have never been super easy to deploy, and there are both pros and cons to the ways they鈥檝e changed over time. Find out how 海角天涯社区鈥檚 comparison and deployment engine helps you overcome the challenges of deploying Flows and Schedule-Triggered Flows, or get started today on a .

Ready to get started with 海角天涯社区?