How to Reset the Flow Limits

How to Reset the Flow Limits

Flow is the number one automation tool of Salesforce. There are endless things that you can achieve using Salesforce Flow. However, just like any other tool in Salesforce, flow has limits too. Salesforce provides a single application to multiple organizations, which makes it a multi-tenant platform. Therefore, Salesforce enforces limits to make sure that flows don’t take over the shared resources in the multi-tenant environment.

Transaction is a group of operations that are executed as a single unit. There are some governor limits that apply per flow transaction. For instance, total number of SOQL queries issued (100) and total number of DML statements issued (150) are the most famous limits. If an element in the flow causes the transaction to exceed governor limits, the entire transaction is rolled back. Therefore, when you design a flow, you have to keep the limits in mind. For example, if a flow transaction has more than 100 Get Records (SOQL) elements, it will exceed the governor limits and cause the flow to fail. Although these limits sound high, it is possible to exceed them in complex flows that have loops.

Since these limits apply per flow transaction, it is possible to reset them by ending the transaction.

How to End the Flow Transaction

Even though it sounds like a great cheat, actually it is not a cheat. Well, at least it is not a secret, it is written in the official Salesforce articles. On the other hand, when you debug a screen flow or an autolaunched flow, after each DML operation, it shows a message. This message contains the ways to end a flow transaction.

Ways to reset flow limits

When a flow executes a screen, pause, or local action, the flow transaction ends. However, these elements are available only in some of the flow types. Let's see how to end a transaction in screen flows and autolaunched flows.

How to End the Flow Transaction in Autolaunched Flows

Out of these three ways, only the Pause element is available in autolaunched flows.

Pause

Using the Pause element, you can pause the flow. Then it resumes when a specified time occurs or when a platform event message is received. Although it sounds like the flow will wait for a long time, you can configure the Pause element to pause the flow for 0 hours. By doing so, this element will end the flow transaction, which will reset the flow limits. After a very short time, the flow will continue with the next element.

Pause 0 Hours

How to End the Flow Transaction in Screen Flows

The Pause element is not available in screen flows. However, the remaining two options are available.

Screen

Screen flow is the only flow type that supports the screen element. Using screens, you can get input from the users or display whatever you want. When the flow executes a screen element, the flow transaction ends. It means that it commits the pending record changes to the database and resets the flow limits. It is a good way to reset the flow limits but sometimes it is not the best option. For example, if you have a loop that might hit the limits, it is not the best practice to display a screen just to reset the limits.

Local Action

Local actions are Lightning components that execute client-side logic. Using the local actions, you can perform actions in the browser instead of going through the Salesforce server. Since Lightning components require a browser context to run, local action components are supported only in screen flows. On the other hand, autolaunched flows execute on the server. That it is why local actions cannot be used in autolaunched flows.

Local actions can perform many actions. For example, you can use them to navigate to a record, close the browser, or get data from a database behind your firewall.

If you want to use a local action just in order to reset the flow limits, you can build an empty one that is not doing anything. Or you can install this component from UnofficialSF and use it in your screen flows in order to commit transaction. Once you have a local action, you can find it under the Action element in your screen flows.

Local action to commit transaction

Summary

You can use a pause, screen, or local action in order to end a flow transaction and reset the flow limits. It is important to use the correct element and make sure that it is not causing a bad user experience.

You can also use an assignment element to count the data element usage. If the flow is going to hit the limits, you can add a decision element to execute one of these elements in order to reset the limits.

1 Trackback / Pingback

  1. New Flow Features of Spring '23 Release - Salesforce Time

Leave a Reply

Your email address will not be published.


*