It seems fairly standard practice to create reminder tasks to nudge reps about neglected opportunities. We do that for open opps that haven't been modified for 30 days, and for renewal opps when they get within 90 days of the renewal date. Do your reps always take action? Yeah, mine don't either.
My concern is that these reminders become noise. The few new alerts get crowded out (attention-wise) by all the alerts that have been sitting around neglected. The net is that reps learn to ignore these alerts, and they become pointless. What to do?
One step I've taken is to automate cleanup of certain old tasks. This post and the next will walk through the steps I've taken. My aim is to (1) delete any 'Not Started' tasks associated with opportunities when the opportunities get closed, and (2) delete any duplicate reminder tasks on a given opportunity when creating a new such task.
To do this, I'm going to create a flow which, given an opportunity id, will delete a set of associated tasks. There are really two flavors of the flow. One flavor will take as input an opportunity id and will delete all tasks with status of Not Started (I'll subsequently refer to these more simply as Open Tasks) related to the same opportunity. The second is triggered when a new task is created, and it deletes only Open Tasks with the same subject which are related to the same opportunity and assigned to the same user.
Today's focus is creating the flow. After launching Flow Builder, I first switch to the Manager tab and create the variables I need. For each variable, I use the New Resource button, and create a total of five variables:
Each outcome leads to a GetRecords element, which is essentially a SOQL query built via clicks. For the 'HasTaskID' branch, I'm looking for Tasks that match the inputs varOppId and varOwnerId, whose id is NOT equal to varTaskId (that's the task just created; I want to create duplicates, not the new task itself!) and whose status is Not Started. I assign the resulting collection to varTasks and, if no results are returns, set varTasks to null.
My concern is that these reminders become noise. The few new alerts get crowded out (attention-wise) by all the alerts that have been sitting around neglected. The net is that reps learn to ignore these alerts, and they become pointless. What to do?
One step I've taken is to automate cleanup of certain old tasks. This post and the next will walk through the steps I've taken. My aim is to (1) delete any 'Not Started' tasks associated with opportunities when the opportunities get closed, and (2) delete any duplicate reminder tasks on a given opportunity when creating a new such task.
To do this, I'm going to create a flow which, given an opportunity id, will delete a set of associated tasks. There are really two flavors of the flow. One flavor will take as input an opportunity id and will delete all tasks with status of Not Started (I'll subsequently refer to these more simply as Open Tasks) related to the same opportunity. The second is triggered when a new task is created, and it deletes only Open Tasks with the same subject which are related to the same opportunity and assigned to the same user.
Today's focus is creating the flow. After launching Flow Builder, I first switch to the Manager tab and create the variables I need. For each variable, I use the New Resource button, and create a total of five variables:
- varOppId - this is a text variable, available for input, and represents the id of the opportunity whose tasks I'll consider deleting. This is the only input that I'll set when closing an opportunity; the other inputs (as well as this one) apply when creating a task
- varOwnerId - this is a text variable, available for input; it's the id of the owner of the newly created task
- varSubject - this is a text variable, available for input; it's the subject of the newly created task
- varTaskId - this is a text variable, available for input; it's the id of the newly created task, with a default value of {!$GlobalConstant.EmptyString}. The default value is how I'll differentiate the two flow flavors
- varTasks - this is a record variable, able to contain multiple values (that is, a collection)
With the variables defined, it's time to create the flow. The first step is to determine which flavor of the flow to run. That's determined by whether the input varTaskId is null, so I have a decision element. The two outcomes are HasTaskID (that is, varTaskId is not equal to {!$GlobalConstant.EmptyString} and NoTaskID (the default outcome).
**CAREFUL** You may want to be more specific with your SOQL criteria, perhaps requiring that the Subject is 'Reminder', the WhoId is blank, etc. If your criteria are fairly liberal, you may delete more than intended!
The SOQL query for the NoTaskID outcome is simpler; only the criteria for Status and WhatId apply. Here too, the results are assigned to the varTasks collection variable, which is set to null if no results are returned.
Both of these GetRecords elements flow next to a decision which simply tests whether varTasks is null. The outcome representing varTasks is NOT null leads to a Delete Records element. I delete records using the ids stored in the varTasks collection variable.
So that's the entire flow... Along with the five variables, I have two decisions, two 'gets' and one delete element.
After some testing (the Debug feature of flow builder ROCKS), I saved and activated the flow. I named it DeleteUnstartedTasks (this comes up when it's time to invoke the flow from Process Builder), and its type is Autolaunched Flow.
Next time we'll use Process Builder to launch this flow under the two circumstances - an opportunity being closed and an open, opportunity-related task being created.
Trailhead reference: https://trailhead.salesforce.com/content/learn/trails/build-flows-with-flow-builder
Comments
Post a Comment