This article will explain how to automate the deletion of paused flow interviews in Salesforce so your users can circumvent errors and ensure you will not hit the paused flow interview limit.
If you have experimented with paused flows, I am sure you have encountered one of the following issues:
- Cannot delete a record with a paused flow
- Cannot convert a Lead with a paused flow - receive error 'Unable to convert lead that is in use by workflow' - if you are experiencing this issue, check this article out too.
- Cannot activate a Contract with a paused flow
Another issue is you have a 50,000 limit on Paused Flow Interviews in your org. Currently, there is no way to identify which record a Paused Flow Interview record is for, unless you stamp the Flow GUID on the record that started the flow.
The solution is for the System Administrator to delete the paused flow interview from Setup or delete them in mass via data loader. This is not a desirable solution in all scenarios. Let me explain further ...
Let's say you have a process builder that invokes a flow which waits for 2 days to send a reminder email only if the Lead Owner has not updated the Lead Status = Contacted. Now let's say the Lead Owner updated the Status = Contacted after 1 day and then wants to convert the Lead. They won't be able to until the paused flow interview record has been deleted. The solution is to delete the Flow Interview record when the Lead Status is changed to Contacted. Great idea, so how do we do automate this?
We have created a free AppExchange package that contains the components you will need to delete Paused Flow Interviews on the Lead object. The package contains the following:
- Lead Flow Id (Custom Field on Lead Object) - this field stores the Id of the paused flow interview record so we can find it to delete it.
- Delete Paused Flow Interview Record (Autolauched Flow) - this flow can be reused for any object and can be used as a subflow or invoked by a process builder.
Next go to Flows and then find the Delete Paused Flow Interview Record flow you installed from the package. Click Activate
Now we are going to add a criteria action group to our process builder to delete the Flow Interview record whenever the Lead Status = Contacted. This will make sure we are cleaning up the paused flow interviews as we go and make sure we do not run into an error when converting the Lead.
Make sure to Activate the process builder and you are ready to test it out!
Now the cool part about this is you can reuse the Delete Paused Flow Interview Record flow you installed from the package for any object. You just need to create a custom field on the object to hold the Flow Id and make sure to pass the value from the Flow Id field to the varFlowId variable in the flow via process builder.
If you need instructions on how to convert a current process builder using scheduled actions to using a process builder with a flow, check this article out.
Any comments, questions, concerns – let us know in the comments! We would love to hear from you!