2 New Salesforce Flow Features That Address CPU Timeout Errors

Salesforce now provides new flow features for CPU timeout errors caused by process builder. Features such as scheduled flows and running a flow before saving can now make your automation process much simpler.

If you’ve read our previous post on using flows in Salesforce, you’ll already know that we love them. Salesforce is constantly adding new features and making improvements to flows. As a result, we’re advising admins more and more to choose flows over other automation options. To our delight, Salesforce’s Winter ’20 and Spring ’20 releases have given us two more reasons to be excited about them. In particular, there are new ways to avoid CPU timeout errors caused by process builder.

Flows Now Run Before Save (Spring ’20 Release)

This great new feature has a major limitation—but it can be managed.

If you struggle with CPU errors in Salesforce, take note of this new feature, which allows you to kick off a flow from a record change before save. This means that flows can now operate on data while it is en route to the database, and before other automation runs. (That is, everything except validation rules).

There are many reasons that using flows is preferable to using process builder. Thanks to this new feature, many of the processes you would normally have to run in a process builder can now happen in flows. Using flows, these processes will be up to 10x faster and won’t cause recursion. Most importantly, using flows for functions like updating a date field will eliminate the strain that process builders can put on your CPU limit.

Beware of one major limitation here: When your flow happens before save, you cannot filter it on change events. Instead, you will need to indicate within your flow that it should take action only when a specific change happens.

For example, in the flow below, our client wanted to assign a record only when the contact status field value changed to a particular value. We configured the flow to fetch old contact values, and then used the previously met decision to compare the newest field value to a previous value to determine whether it had changed to meet the status in the condition. If we hadn’t configured this field value comparison, the flow would fire on every record with the contact status value in question, whether it was a change or not.

Scheduled Flows (Winter ’20 Release)

We’ve written at length about scheduling your automation, both declaratively and in Apex code. As we recently mentioned, one of the best ways to schedule your automation, made possible by changes in the Winter ’20 release, is to use scheduled flows.

Scheduled flows are another good automation choice to help steer you away from process builders and the CPU timeout errors they can create. Scheduling flows is useful for tasks like sending an email alert based on a date field. For example, have a look at the flow below, which triggers an email alert and is scheduled to run daily. Unlike a process builder, which needs to be triggered on a record change, this scheduled flow scans the system at a specific time each day to determine whether action should be taken based on the conditions set.

You’ll need to be aware of some limitations with scheduled flows: You can only schedule the flow to run once per day, and you are unable to control the number of records that are processed per batch. So pay attention to make sure you won’t run into volume-related errors, and stick to process builders when necessary.


Need a Salesforce