I have a flow that only fires once per case record when an email-to-case comes in. It finds the email alias the case came through and assigned some values to the case record.

I'm assessing a flow that has the DML statement inside a loop with an End (see example first image). It makes sense since the DML statement can only and should only be executed once. However, unsure if it follows best practice or if necessary to bulkify.

I have a mock up of what removing the DML statement out the loop might look like (see example second image), but is it correct or necessary? And I have no idea how this could be bulkified (or even if it needs to be). In this post it wasn't clear if bulkification was needed: DML in the Loop followed by break. Still getting to grips with all this. Thanks

Example First Image: (DML inside loop followed by end/break)

enter image description here

Example Second Image: (DML outside of loop trial)

enter image description here

  • 2
    Does this answer your question? Do we need to "Bulkify" Flows?
    – identigral
    Commented Sep 7, 2023 at 17:26
  • Hi @identigral, it doesn't quite answer it. This question is more related to scenarios where case creation will happen one at a time, and there won't be any need to update multiple records at the same time. The question is whether bulkification is needed in scenarios like this.
    – eHarazi
    Commented Sep 8, 2023 at 8:31

1 Answer 1


Best practices around bulkification are designed to ensure your automation stays under the governor limits.

Because you have an end element in the loop, the loop won't overconsume system resources. It'll do a single update and then end, using 1 DML statement.

By using assignments, you'll stick the record in a collection and then update it outside the loop, which also uses 1 DML statement.

To me these are equivalent and so while best practice says "never put a DML statement in a loop" I think this is technically fine.

My follow-up question would be, why use a loop at all?

Why not just use the update records element to find the specific record based on your conditions and then update it?

  • Hi Nick. Big fan of your courses on Udemy. With that said, you make a valid point about not requiring a loop here. However, in this example scenario flow that will only fire once per case creation, is there any need to bulkify. As in, if two customers fire an E2C case at the exact same time, will Salesforce handle bulkification here?
    – eHarazi
    Commented Sep 8, 2023 at 8:39
  • 1
    Thank you! The scenario of two flows triggering at the same time is handled by Salesforce with separate transactions and we don't need to worry about this as much. Keeping Update and Get elements out of loops is best practice and bulkification in this context means your loop can execute successfully on 1 or 200+ records. If you have a scenario where you loop through 150 records, use an update element once inside the loop, and end the loop with the end terminator, then the flow still executes successfully on 1 or 200+ records without hitting a limit and to me is still "bulkified". Commented Sep 11, 2023 at 23:04

You must log in to answer this question.

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