How Scheduled Flows work in Salesforce?
Scheduled flows are essentially a low-code version of Scheduled Batch Apex. You can only query up to 50,000 records in a regular transaction (Governor limit). Batch Apex, on the other hand, allows you to query up to 50 million records.
Similarly, Scheduled flows allow you to query more than 50,000 records, but only if the item in the Start element is selected.
If you’re a developer, think of this Start element as the Batchable interface’s ‘start’ method.
If you try to query records with the normal Get Records element, you’ll reach the SOQL limit of 50,000 records. To query the records, you should use the Start element.
Because you’re extremely likely to iterate over a large collection of records, querying records using the Start element not only helps you avoid hitting the SOQL limit, but it also helps you avoid hitting the 2000(Maximum) elements executed restriction.
NOTE: You might get around this restriction by utilizing Apex actions, but that defeats the point of a low-code approach.
So, after querying all of the records, the flow breaks the queried record list into 200-record chunks and conducts 200 flow interviews, one for each chunk. The chunking is done to make sure you don’t go over the Governor’s limit.
Is it possible for Scheduled Flows to query 50 million records as well? No, that is not the case.
Scheduled Flow Query Limits
As a result, when picking Scheduled flow for your solution, the following limitations should be the most important consideration:
Within 24 hours, the total number of records produced by all scheduled flow filters in your org cannot exceed 250000, or the number of user licenses in your org multiplied by 200, whichever is greater.
Alternatively, the maximum number of schedule-triggered flow interviews per 24 hours is 250,000, or 200 times the number of user licenses in your org, whichever is greater.
Record locking issue in scheduled flows
Record locking difficulties can occur in scheduled flows (they happen all the time)! So, what are our options for dealing with them?
The most common and first course of action for Batch Apex is to reduce the batch size. Scheduled Flows, on the other hand, do not allow you to adjust the batch size. They only run in 200-record batches. I know how sad it is!
So, what are your options?
- You could try sorting the records based on a field.
- You can use the Pause element before the Update Records element, however, keep in mind the 1 MB maximum flow interview size limit in case you need to query some records lower down the flow.
- The best (but time-consuming) way to minimize record locking issues is to evaluate what all automations are running on the update and adjust your strategy accordingly.
See here to know the latest updates on Salesforce