Skip to main content

Task Cleanup - Launching the Flows

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.

Process builder criteriaNow 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:
Process Builder - setting the flow variables

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

Popular posts from this blog

Salesforce Pipeline Reporting - part 1 of 3

In a dozen (plus) years working with Salesforce, I've never been entirely happy with the built in reporting of my opportunity pipeline. I can export details, or a printed (formatted) view, but I lose the interactivity. I can use a dashboard, which is better now in Lightning in that I can see a lot more fields in a table component. But flexible views require filtered dashboards, and just maintaining the filter values (if they go down to a rep level) can be onerous. Plus applying (or removing) a filter tests my (very limited) patience. So I've typically exported the report details into Excel, and there created a workbook that includes (1) summary info, (2) scrollable deal lists with hyperlinks back to the opportunity records in Salesforce and (3) filters that let me instantly switch views, say among teams, reps, opportunity types, or fiscal periods. My process around this involved LOTS of VBA and LOTS of formulas. Lately, I've (finally) gotten turned on to slicers in Exc...

Using Excel with Salesforce: One tool, two tips

Obviously, Salesforce has strong built-in reporting tools. And I'm a big fan of the dashboards, especially filtered dashboards and dynamic dashboards. WAY better than the old approach of creating a unique set of reports and a corresponding dashboard for every conceivable view. Still, I often want to pull my Salesforce data into Excel. This might be for further manipulation / processing, aggregating data that doesn't live in Salesforce, or distribution to non-Salesforce users (hey, those licenses are expensive!). Reporting Tool - XL-Connector: I'm using a new (to me) tool when I have to repeatedly pull Salesforce data into Excel: XL-Connector  (fka Enabler 4 Excel) from Xappex. There's a lot you can do with XL-Connector. My primary use is just to extract data from Salesforce, and this can be done in two ways: reports or SOQL queries. The great part is that once you've captured data into an Excel file, refreshing the data is trivial. I've stored my credential...

Salesforce reporting: XL-Connector and VBA

In an earlier post , I mentioned a tool I'm using to import Salesforce data - via SOQL or existing reports - into Excel. This post is more about using that tool, XL-Connector from Xappex . Here, I'll walk through the (simple) process of importing and refreshing a report, and I'll provide a simple VBA macro to automate the refresh. In a future post, I'll expand on that macro to show a friendly view of my opportunity pipeline and a single-page view of how each of my sales reps are doing against a series of KPIs. Importing a report is simple enough. From the XL-Connector tab, select Log In and enter your credentials. I'm using the old id and password (as opposed to SSO), so I provide that along with my 'token'.  (Don't remember your token? Log in to Salesforce via your browser, click on your photo, select Settings, then 'reset my security token'.) Once you're logged in the lock turns green. Back in Excel, on the XL-Connector tab, select ...