Skip to main content

How to delete flows with Gearset

How to delete Salesforce Flows using Gearset, how the problem analyzers handle versioning and active Flows for you, and what to do when paused or failed Flow interviews block the deletion.

Written by Josh Camilleri

Deleting a Flow in Salesforce is often more difficult than people expect. You can't delete an active Flow, and from Metadata API v44 onwards you have to list every version of the Flow that exists in the target before Salesforce will let it go. Done manually, that usually means hitting errors like Insufficient access rights on cross-reference id or You cannot delete this Flow version because it is active.

The good news is that Gearset's problem analyzers handle most of this for you, so the deletion itself is simpler than it first appears.

Deleting a Flow through your Pipeline

  1. Deactivate the flow in your sandbox and then delete it.

  2. Select and commit the deletion of the flow to your feature branch. (Not the FlowDefinition)

  3. Open a PR to the first environment in your Pipeline.

  4. The validation should be successful but we will include the FlowDefinition in the package when deploying. This can be checked by viewing the validation:

  5. Promote the PR through your Pipeline!

Two problem analyzers do the heavy lifting here:

Deleted active Flows - if the Flow is active, this analyzer deactivates it before the deletion so you don't hit the "cannot delete an active Flow" error.

Must delete all versions of a Flow - on API v44 and above, Salesforce requires every version of the Flow in the target to be listed for the deletion. Gearset checks the versions that exist in your target org and replaces the single unversioned deletion with all the versioned Flows, so the deletion goes through without the Insufficient access rights on cross-reference id error.

When the deletion fails: paused or failed Flow interviews

If a Flow has paused or failed Flow interviews referencing the version you're trying to delete, the deployment will fail even with the problem analyzers applied. A Flow interview is a running instance of a Flow, and while those interview records exist Salesforce will not let you delete the underlying Flow version.

This typically shows up as a generic Salesforce error along the lines of This flow version is referenced elsewhere in salesforce.com. Remove the usage and try again. Flow Interview . This is a Salesforce-side restriction, so it isn't something Gearset can work around for you the interviews need to be cleared first.

To resolve it:

  1. In Salesforce, go to Setup and search the Quick Find box for Paused and Failed Flow Interviews.

  2. Find the interviews associated with the Flow you're trying to delete.

  3. Delete those interview records. You can remove them one at a time from this page, or use a data tool (such as Data Loader or Workbench) to delete them in bulk if there are a lot.

  4. Once all the paused and failed interviews for that Flow are gone, run your comparison again and retry the deletion in Gearset.

With the interviews cleared, the deletion should now complete successfully.

Disclaimer: some of these errors are returned by Salesforce directly, rather than Gearset. Even so, we offer guidance based on our combined experience with the Metadata API. Where possible, we try to help guide you to fix or avoid the error. In cases where this isn't possible, we may need to direct you to Salesforce support for further clarification.

Did this answer your question?