This article will explain how to convert your process builder from using scheduled actions to using paused flows. Please review this blog post prior to reading this one, it will help further explain deleting paused flow interviews. You may have run into one of the following issues when using either time-based workflow or a process builder using scheduled actions:
- 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’
- Cannot activate a Contract with a paused flow
Process Builder with Scheduled Actions:
In this example, we have a process builder that sends two emails, one when the Lead is created and the other 6 days after the Lead is created.
If a user wants to convert the Lead prior to this date, they receive an error Unable to convert lead that is in use by workflow. The solution from Salesforce is to go to Setup | Paused Flow Interviews and delete the paused flow that is causing the issue. Good luck in finding which one it is if you have many to choose from! Our recommendation is to replace the scheduled actions with a paused flow.
How to Convert Scheduled Actions to Paused Flow Interviews:
Here is a view of the entire process builder you will need to build in order to replace the scheduled actions with flows, so your users can convert Leads without getting an error. You will need one process builder, two flows and a custom text field on the Lead. This AppExchange package contains one of the flow and the custom field you will need.
Now let’s break it down, step by step. We can see that when the Lead is created we are invoking a flow to send the emails instead of using the scheduled actions. Make sure to set the flow variable for the Lead Id.
Here is what the flow looks like that sends the two emails:
First, we update the Lead with the Flow Id, this is so we can find the Flow Interview Record if we need to delete it later. Here is a screenshot of the Update Records – Update Lead w/ Flow Id element:
Then, we send the first email to the Lead using an Email Alert. This action uses the same email alerts you are using in workflows.
Next, we use a Pause element to wait for 6 days after the Created Date to send the 2nd email. Set the element to wait for a specified time and to use a record field.
When 6 days passes, we lookup the Lead to make sure the Lead Status = Open with a decision element. If it is Open, then we send the email.
Last, we remove the Flow Id from Lead record so it does not cause an issue later.
In this scenario, the Lead went through the entire flow and received both emails. But what if the user wants to convert the Lead before 6 days has passed? If you look at the process builder, there is a 2nd action group which is looking for the IsConverted = True and Lead Flow Id to have a value.
When this criteria are met, the process builder invokes the flow and passes the Lead Flow Id to the flow:
This flow looks for a Flow Interview Record that has a Flow GUID = Lead Flow Id. If it finds a match, it deletes the record. Here is an overview of the flow, this flow is part of this AppExchange package.
Next, the process builder removes the value from the Lead Flow Id field.
Let us know if this was helpful, looking forward to hearing questions and feedback in the comments!