Everytime you deploy a Flow to a Salesforce org, a new version is generated. And when you are iterating, you can easily reach the 50 flow-version limit!
For this reason, and others, purging old versions of a flow may be necessary:

Until now, the following solutions were available:
- Delete manually old flow versions one by one (be brave if you have more than 20 old versions to delete);
- Execute a SOQL query to export flows and delete them with Salesforce Inspector (works pretty well but can be painful for a non-developer)
But your world is about to change, with the “Mass delete Obsolete flow versions” feature in sfdx-hardis by Cloudity!
Cloudity Open-Source initiative provides a free command allowing to:
- Select flows to delete
- Filters on flow status:Draft, Obsolete, Inactive….
- Delete appropriate flows

Pre-Requisites
- Please follow sfdx-hardis installation instructions,
- Launch Visual Studio Code in an empty folder (or a sfdx project if you have one),
- And open sfdx-hardis extension.
Now that you are ready to start, click on the menu ‘Purge obsolete flow versions’:

Connect to the org where you need to work:


Select the flow to purge in the drop-down list (the “All flows” value allows you to purge all of the org’s flows):

Filter by the flow status:

Confirm deletion

Wait for the mass delete to be completed. Depending of the number of flows to delete, it can take a while.

If you need to automate the purge (CI jobs, CRON…) , you can directly use sfdx-hardis command sfdx hardis:org:purge:flow.
And that’s it! Your org is much tidier now thanks to the sfdx-hardis open-source tool. And it only took minutes!
Article written by Dimitri Monge, Technical Manager.