1

I want to do an update of a set of records on a daily basis with a flow. We are talking about 5,000 records on a batch. The issue I'm having is that when I assign the individual records to a variable and then to a list variable on a loop, I'm using all of the allowed iterations.

Is there a way to get my data and update it all together without having to loop to save the individual records?

2

3 Answers 3

3

You cannot avoid writing a loop, either in Apex or Flows.

You have to write your own batches, as noted in this help topic.

Here's what that looks like:

enter image description here

The "secret sauce" is that we use the Pause element to reset our limits. For efficiency, set your batch size to a reasonable value.

Here's some relevant screenshots for the various elements:

Assignment

Decision

Clearing Temp list

Pause Conditions

Short Pause

I hope that this provides enough information for you to get started.

2
  • Thank you! Super detailed explanation. Can't even remember how many times you have saved me.
    – ErFran
    Commented Aug 16, 2022 at 18:54
  • I am not able to comment or upvote yet therefore would like to share my thoughts and hope it would be helpful. In most scenarios we would need to use Loop element as described by sfdcfox. Let's assume your schedule flow needs to process bulk of records and update certain fields by values from other fields in the same record. For this to work you would need to use the {Current Item from the loop} variable. If you use the $Record global variable it would return null values. Hence this is why just using the Update element, even with filter criteria, would not work here as it does not have acc
    – rayrasul
    Commented Mar 8 at 18:43
0

Yes, you can update multiple records in Flow without a Loop in 2 ways.

If you are using a Schedule-Triggered Flow, you can pick an object and criteria to update those records in a batch.

enter image description here

For a record triggered flow, you add an Update Records element and choose "Specify conditions to identify records, and set fields individually". It will get all records that meet the criteria and update with the values you set.

enter image description here

1
  • 1
    Welcome to Salesforce Stack Exchange (SFSE)! While this answers the general question from the title of the question post, it does not answer the actual question that was asked by the OP regarding iteration limits due to having so many records that need to be individually added to a record collection.
    – Moonpie
    Commented Nov 23, 2022 at 16:40
0

The best answer from sfdcfox really helps! I was able to follow through and build the schedule triggered flow for our SF org.

Just want to add the reference to the SF document for Schedule-Triggered Flow Considerations where it mentions the tip for the pause element:

You can insert a Pause element that pauses the flow for only a moment. Configure the resume event to pause until a specified time, with a specific time as the time source. For the base time, specify the $Flow.CurrentDateTime global variable. Then set the offset to 0 hours. At run time, a Pause element that's set up this way typically pauses the flow for less than a minute.

This is what I wasn't aware when using the 'Pause' element to pause the flow for a moment.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .