3

Do we need batch update records in flows or does Salesforce automatically do this for us?

For example.

with a list of records: [Record1, Record2]

I want to loop through each one in the flow and then update in the following manner

record1.name = 'john' update record1

record2.name = 'matt' update record2

^ Will the above be very inefficient? or does Salesforce not actually update the record until the process builder that called the flow completes?

2 Answers 2

4

Records are updated at the moment you hit an update element. In other words, yes, you must bulkify your flows just as you would in Apex or the API. Place DML operations outside of a loop, or you'll run into limits quickly.

6
  • I am trying to update all the stage of all contacts in my opportunity contact roles to "opportunity". Not quite sure how to achieve this using flow. Jul 30, 2019 at 22:43
  • @MatthewMetros You're have to add the records to a collection, then you update all at once.
    – sfdcfox
    Jul 30, 2019 at 23:16
  • I am looking for documentation online surrounding this. Let me know if you know of anything. Jul 30, 2019 at 23:55
  • 1
    Hi @sfdcfox, I wonder if you disagree with Salesforce official statement "If you’re working with flows, you don’t even have to think about bulkification. Flow interviews bulkify actions for you automatically." in Salesforce Documentation on this Apr 13, 2022 at 1:00
  • 1
    @PasanEeriyagama Flow Bulkification works across multiple records in the same transaction that are using the same Flow. Within the Flow, there are still the concepts of "SOQL inside loops" and "DML inside loops", both of which will work fine in small batches, but start to fail when you exceed governor limits. The documentation says "When multiple interviews for the same flow run in one transaction, each interview runs until it reaches a bulkifiable element. Salesforce takes all the interviews that stopped at the same element and intelligently executes those operations together."
    – sfdcfox
    Apr 13, 2022 at 1:52
5

I've always been under the impression that, as long as you don't transgress certain rules, flows auto bulkify as per:

https://help.salesforce.com/articleView?id=flow_concepts_bulkification.htm&type=5&sfdcIFrameOrigin=null

2
  • That is what I thought Aug 5, 2019 at 11:56
  • Shouldn't this be the answer @MatthewMetros ? Apr 13, 2022 at 1:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.