Delete Flow or Process Builder with Copado

In API version 43.0 and earlier, the Flow object’s fullName field included the flow’s version number. In API version 44, the field no longer includes the version number. As part of this upgrade, flow definitions are no longer necessary when you deploy or retrieve via Metadata API. This also means that the flow version is no longer retrievable and therefore it is not included in GIt. Your Git repository will have only a single file for each flow and this one will be updated every time a new flow version is committed.

More details on the article How to Deploy Flows from v44

Because of the upgrade above, if you try to use the Destructive Changes feature with a Flow, you will receive the error below from Salesforce when deploying the Delete Metadata step.

"insufficient access rights on cross-reference id"

Since the flow version is no longer provided by the Metadata API v44, we do not have access to the version anymore and therefore we cannot specify in Copado the version of the flow that has to be deleted. This is causing the Flow Version deletion not being supported by the Destructive Changes feature.

You can still delete flow versions using one of the options below:

1. Workbench or ANT Migration Tool

In order to delete a flow version, the flow version must be specified in the destructivechanges.xml file provided to Salesforce in during the deployment.
Build a zip file that will contain the .xml files below (destructivechanges.xml and package.xml). By deploying that zip file you will be able to delete Flow versions specified in the target org.

 destructivechanges.xml
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>FlowName-1</members>
        <members>FlowName-2</members>
        <members>FlowName-5</members>
        <members>Example-2</members>
        <name>Flow</name>
    </types>
</Package>


package.xml
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">    
  <version>44.0</version>
</Package>


More details on how to build this file here.

2. Manual Task in Copado

Create a manual deployment task in Copado to remind you that a flow version must be deleted in the target org.


NOTE:

It's not really necessary to delete an old flow version. You can just create a new version, activate it and move it to the next environment without having to delete the previous one. This is the most simple approach when having to update a flow. There is no need to delete existing previous versions of the flow.




 

How did we do?