In the previous post, we set the objective of cleaning up open tasks either when (1) the opportunity to which they are related is closed or (2) another task with many of the same attributes is created. We created an auto-launched flow which determined which of those two flavors was in play, captured the appropriate tasks and, if there were any, deleted those tasks.
What we didn't do last time was launch that flow. That's the exercise now. We'll create two Process Builder flows which invoke the flow, setting the appropriate input variables.
Recall there are two instances in which we're going to launch our flow. The first, and more complex, is when a task is created. If a task is created, it relates to an opportunity and its status is Not Started, I'm going to launch the flow. Let's get started...
From Setup, search on Process Builder, then click on it and then New. Give the process a name, and have it start when a record changes. Next, Add Object and select Task. Start the process when a record is created.
Now we need to set the criteria. I want to ensure that the task relates to an opportunity, and that its status is Not Started (this makes it less likely that it's kicked off by a rep using the 'log a call' action).
My criteria is a formula: AND(LEFT([Task].WhatId,3) = "006",ISPICKVAL([Task].Status,"Not Started")) (Note that '006' is the prefix for the opportunity entity.)
So I know WHEN I want to take action. Next is to specify what that action is. Under 'Immediate Actions', click on Add Action. Select the Action Type of Flows, give the action a name, then use the drop-down to select the flow we created last time: DeleteUnstartedTasks. Recall that the flow has four input variables, and this is where we assign values to those variables. Click Add Row four times, then start filling in the values:
Save and activate. I'm all set to launch the first flavor of the flow.
Now use Process Builder again, creating another new process to invoke the other flavor of our flow, this time when an opportunity closes. This time, the process kicks off when an Opportunity is created or edited. My criteria is again a formula: AND([Opportunity].IsClosed,ISCHANGED([Opportunity].IsClosed)). That is, I'll launch the flow when an opportunity is newly closed. As above, the immediate action is to launch a flow. However, this time, I only need to set the varOppId to [Opportunity].Id. (Recall that my varTaskId was set up in the flow with a default value of an empty string, so I don't need to set that here in order to tell the flow which flavor to launch.)
That's it! Just keep in mind that Salesforce best practice is to have just one record-change process per object (reference: Salesforce help & training). It's likely you already have a record-change process for the opportunity object, so the best practice is to use or create a criteria branch for a newly-closed opportunity to your existing process, and launch the flow from there.
What we didn't do last time was launch that flow. That's the exercise now. We'll create two Process Builder flows which invoke the flow, setting the appropriate input variables.
Recall there are two instances in which we're going to launch our flow. The first, and more complex, is when a task is created. If a task is created, it relates to an opportunity and its status is Not Started, I'm going to launch the flow. Let's get started...
From Setup, search on Process Builder, then click on it and then New. Give the process a name, and have it start when a record changes. Next, Add Object and select Task. Start the process when a record is created.
Now we need to set the criteria. I want to ensure that the task relates to an opportunity, and that its status is Not Started (this makes it less likely that it's kicked off by a rep using the 'log a call' action).
My criteria is a formula: AND(LEFT([Task].WhatId,3) = "006",ISPICKVAL([Task].Status,"Not Started")) (Note that '006' is the prefix for the opportunity entity.)
So I know WHEN I want to take action. Next is to specify what that action is. Under 'Immediate Actions', click on Add Action. Select the Action Type of Flows, give the action a name, then use the drop-down to select the flow we created last time: DeleteUnstartedTasks. Recall that the flow has four input variables, and this is where we assign values to those variables. Click Add Row four times, then start filling in the values:
Save and activate. I'm all set to launch the first flavor of the flow.
Now use Process Builder again, creating another new process to invoke the other flavor of our flow, this time when an opportunity closes. This time, the process kicks off when an Opportunity is created or edited. My criteria is again a formula: AND([Opportunity].IsClosed,ISCHANGED([Opportunity].IsClosed)). That is, I'll launch the flow when an opportunity is newly closed. As above, the immediate action is to launch a flow. However, this time, I only need to set the varOppId to [Opportunity].Id. (Recall that my varTaskId was set up in the flow with a default value of an empty string, so I don't need to set that here in order to tell the flow which flavor to launch.)
That's it! Just keep in mind that Salesforce best practice is to have just one record-change process per object (reference: Salesforce help & training). It's likely you already have a record-change process for the opportunity object, so the best practice is to use or create a criteria branch for a newly-closed opportunity to your existing process, and launch the flow from there.
Comments
Post a Comment