I’ve managed to create quite a few process builder and flows for demonstrating concepts to the community or have had multiple drafts trying to get a flow to work. Either way, if you have quite a few process builders or flows that you’d like to get rid of, this is the fastest way to do it (it’s only worth your time if you have a lot of them).
Open the developer console, go to the “Query Editor” and type the following query with the tooling API selected: SELECT Id, Definition.DeveloperName, VersionNumber, Status FROM Flow WHERE Status = ‘Obsolete’
You should get a screen that looks like this:
(I used to use column copy for this step but that apparently no longer works, which made me a sad panda – since it made this a lot faster).
Right click on the first row and select “inspect” in chrome. Once selected, find the parent div element and select “Edit as HTML” when right clicking. When you click “Edit as HTML” you can paste into excel and make a simple formula to append the version number to the flow name:
My spreadsheet then looks like:
Copy the last column into a file that is called “destructiveChanges.xml”. It should look like:
<?xml version="1.0" encoding="UTF-8"?> <Package xmlns="http://soap.sforce.com/2006/04/metadata"> <types> <members>multi-time process-1</members> <members>Carlos Process-1</members> <name>Flow</name> </types> <version>36.0</version> </Package>
You should then have another file called “package.xml”. This file will have no metadata in it for your deployment. Such as below.
<?xml version="1.0" encoding="UTF-8"?> <Package xmlns="http://soap.sforce.com/2006/04/metadata"> <version>36.0</version> </Package>
Zip the two files together and deploy on workbench using the deploy as single package functionality and all your old process builders should be removed.
Unfortunately, at this time, there is not a faster way to remove process builders / flow. If you have hundreds currently, it is best for you to delete them via the metadata API detailed above. If you only have 10-15, I’d recommend keeping it simple and deleting via the UI.
Great post and a good hack to create the package.xml from the results obtained in the Dev Console. 🙂
My Process Automation Toolkit (OneView) can automate this procedure for you. You can batch select and delete (or reparent) multiple Process Builders or Visual Workflows.
Absolutely brilliant, thank you. I had found a Process Builder process that had a version still marked as Active and was still firing, but it was not present in the UI. I was able to track it down and remove it using this method. Owe you a beer.
I had 60 pb versions,this helped to save my time.
still works like a charm, blew away 520 old versions in my sandbox
was able to run the query using sfdx/CLI , which makes it a tad easier – no inspect html stuff required
sfdx force:data:soql:query -t -q “SELECT Id, Definition.DeveloperName, VersionNumber, Status FROM Flow WHERE Status = ‘Obsolete'” -r csv > flows.csv
and voila CSV file!
problem: insufficient access rights on cross-reference id
i am getting error when trying to delete Process builder using same method .Can you please help if i am missing something
It looks like you’re trying to delete the processbuilder itself without the versionId per the article required. You may want to also review this unofficialsf component – https://unofficialsf.com/flow-and-process-builder-list-view-with-batch-delete/