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:
![](https://cloudity.com/wp-content/uploads/2023/04/1_eDzFsuE4kFIxFIBU3oQ4yA-1.webp)
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
![](https://cloudity.com/wp-content/uploads/2023/04/1_KCdOU7J2aJVdeEeytyHEyg-1.gif)
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’:
![](https://cloudity.com/wp-content/uploads/2023/04/1_zSROkPy7DyDfj6DoDUgQQw-1.webp)
Connect to the org where you need to work:
![](https://cloudity.com/wp-content/uploads/2023/04/1__lOtVRUqXHWWkmMXyvQOFA-1.webp)
![](https://cloudity.com/wp-content/uploads/2023/04/1_ZZTywT-_EkO8l_NywqVK5w-1.webp)
Select the flow to purge in the drop-down list (the “All flows” value allows you to purge all of the org’s flows):
![](https://cloudity.com/wp-content/uploads/2023/04/1_cMeqGRiljHHZ7iCTtud0Gw-1.webp)
Filter by the flow status:
![](https://cloudity.com/wp-content/uploads/2023/04/1_AOOz939yHhBm5ixcTIvDIg-1.webp)
Confirm deletion
![](https://cloudity.com/wp-content/uploads/2023/04/1_EXn43LCkeiUqFt0X4HMD6A-1.webp)
Wait for the mass delete to be completed. Depending of the number of flows to delete, it can take a while.
![](https://cloudity.com/wp-content/uploads/2023/04/1_vM4eDpqiG_p0rKM6N1LP5A-1.webp)
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.