Deploying a Flow as a Destructive Change does not work out of the box (
insufficient access rights on cross-reference id) but there is a workaround.
Important
A green status badge means the issue was successfully reproduced.
A red status badge means the issue was fixed or the pipeline failed for another reason.
When trying to delete a Flow with a destructiveChanges.xml or destructiveChangesPost.xml like this:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Set_Account_Description</members>
<name>Flow</name>
</types>
</Package>You'll get this error message:
insufficient access rights on cross-reference id
It is possible to deactivate the Flow and delete all inactive Flow Versions in a single deployment:
Deactivate a Flow: Deploy a FlowDefinition (flowDefinitions/Set_Account_Description.flowDefinition-meta.xml) with active version number 0:
<?xml version="1.0" encoding="UTF-8"?>
<FlowDefinition xmlns="http://soap.sforce.com/2006/04/metadata">
<activeVersionNumber>0</activeVersionNumber>
</FlowDefinition>Delete inactive Flow Versions using destructiveChangesPost.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Set_Account_Description-1</members>
<members>Set_Account_Description-2</members>
<name>Flow</name>
</types>
</Package>Bug reports and forums
- Known Issue: Deletion of flow metadata through destructive changes not supported
- StackExchange: Insufficient access rights on cross-reference id when reverting a flow in CI/CD pipeline
Open Source Tools
- sfdx leboff:flows:deactivate
- sfdx leboff:flows:delete
- sf hardis:org:purge:flow
- sf ziemniakoss:flows:deactivate
- sf ziemniakoss:flows:purge
- sfdx-git-delta PR to apply workaround for Flow deletions
- sfdx-git-delta PR to warn about Flow deletions
Vendors