Cloud for Good
Search
Close this search box.

Making it Seamless: Autolaunched Flows and Custom Settings

There are some exciting changes to look forward to in the Salesforce Spring ’15 release. According to the release notes, the new Lightning Process Builder tool that was announced at Dreamforce will become generally available*. It is currently available through a private beta program.

In the release notes, you’ll also see that “trigger-ready flows” (also known as “headless flows”) are being renamed to “autolaunched flows”, and one of the interesting things you can do with Process Builder is create an autolaunched flow, which is a flow that doesn’t require user interaction. As a side note, this functionality was also briefly available through the “flow triggers” pilot program; flow triggers were a type of workflow action that allowed you to launch a trigger-ready flow and pass parameters into variables in your flow. Flow triggers were superseded by the Process Builder.

How Autolaunched Flows Can Make It Seamless

Now that we’ve gotten the semantics out of the way, let’s talk about how autolaunched flows can help your users, and how you can combine them with custom settings to make your life as an administrator easier.

One of the things that flows are wonderful for is creating a set of new records based on different variables and criteria in your flow. In the past, creating new records automatically would have required a trigger. But now, with autolaunched flows, you can do it all with clicks instead of code, and make the experience seamless for your users.

For example, one of our nonprofit clients offers classes. Each class follows a specific curriculum, covering a different topic each week. To support this use case in Salesforce, we created a master object called Class and a child object called Class Session. Then, we combined custom settings with an autolaunched flow to automatically create all the child Class Session records when a new Class is created.

Creating Custom Settings

Because each Class is offered many times throughout the year, and the curriculum changes year to year, it was important that the staff be able to easily update the names of all the Class Sessions that are included in each curriculum. In order to keep the Class Session creation flow as low-maintenance as possible, we created a hierarchy custom setting called Class Session Custom Setting, with checkbox fields for each of the possible curriculum values. If you haven’t worked with custom settings before, they are similar to custom objects, and although they are under a different menu in Setup, they will appear in reports and Process Builder just like a regular custom object.

Then, we added custom setting records for each of the possible class topics for each curriculum. Adding this data is very similar to adding records on a custom object. When the curriculum for a class changes in the future, new custom settings records can be added for new topics and old ones can be changed or deleted without affecting existing records in Salesforce.

Building the Flow

Next, we developed our flow. A Decision element at the start of the flow determines which sort of Class Session records to create, based on a variable that stores the curriculum for the Class. A Fast Lookup element for each curriculum finds the Class Session Custom Setting and selects all the records that apply for the specific curriculum and assigns them to an sObject Collection, which is basically the list of “inbound” Class sessions. Then, a Loop element selects a single record from the inbound list, and Assignment elements in the Loop assign values to the new record and collect them into an outbound list. Finally, a Fast Create element creates all the new Class Session records that have been collected.

Using Process Builder to Autolaunch the Flow

Finally, in order for the flow to automatically create all the Class Session records when a Class is created, we used Process Builder. Check out the documentation about Process Builder here. In Process Builder, you first choose an object and specify when to start the process. In this example, we wanted our object to be Classes, and we elected to start the process when a record is created. Second, you can define criteria that will determine whether your flow should launch. In this case, we wanted all new Classes to have Class Sessions created for them, so we selected “No criteria—just execute the actions”.
Then, we added an immediate action to launch the flow.

We also passed the ID and curriculum of the Class into the corresponding flow variables.
Finally, we activated our Process.

Once you are done testing your autolaunched flow in your sandbox, you can move it to production using a change set. The Process will be under the Flow Component Type when choosing components to add to your change set.

As you can see, by combining custom settings with a flow, and automatically launching that flow with Process Builder, you can make data entry much easier for your users, and simultaneously make your life easier as an administrator. If you weren’t already looking forward to the Spring ’15 release, I hope you are now! To find out when your instance will start seeing Spring ’15 features, go to http://trust.salesforce.com/trust/maintenance/

*Keep in mind that, as the release notes say, “Any unreleased services or features referenced in this or other press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.”

Here’s some other posts you may like: