Flow / Admins

Why Loops, Collections, and the Transform Element Matter in Salesforce Flow

By Mariel Domingo

Updated June 02, 2026

It’s all well and good if you know the “whats” of Salesforce Flow: what a loop is, what a collection is, and how they work individually. They’re all useful elements in their own right, but the real power of Flow is knowing how these building blocks can come together.

In this article, we’re focusing on a common practice and use case: bulkifying flows and why these elements are almost always used together to accomplish that. And where does the newer Transform element fit into all this?

Why Loops and Collections Work Hand-in-Hand

On its own, a loop is simple. It lets you go through records one at a time. That sounds fine – so naturally, your first instinct might be to use it for updating multiple records at once. After all, it sounds perfect for that! So why not just drop an Update Records element right inside the loop?

And technically, that does work. Your flow will run an update for every record. But this is a trap, because it’s one of the fastest ways to hit governor limits. Instead of one clean bulk update, you’re suddenly running dozens of tiny updates because every single time your flow goes through a record in that loop, the Update Records element is executed.

Specifically, Salesforce only allows 150 database operations (DML statements) per flow transaction. Each data element (like Update Records) that’s fired triggers one DML statement. Since each Update inside a loop will count as a separate DML statement, updating 150 records this way would already max out the limit! If a 151st record comes along, your flow will fail and roll back.

This isn’t the time to dive deep into Flow limits, but here’s the key thing to remember: the same limits that govern Apex also apply to Flow. Even though Flow feels more declarative and more like “clicks not code,” everything you build still runs as code behind the scenes, so it makes sense that Salesforce enforces the same rules on both. Best practices (like bulkifying) matter just as much for admins as they do for developers! 

With that said, “Where do we put the Update Records element then?” you might ask. This is where collections become useful. So instead of putting your data element in the loop, you:

  1. Start a loop on your records.
  2. Use an Assignment inside the loop to apply your changes and set variable values.
  3. Add those to a new collection variable.
  4. After the loop ends, run a single Update Records on that whole collection.

Check out this example on the same concept, but using the Create Records element as the ultimate data action after the loop.

The example above shows a loop that goes through each uploaded file on a Screen element. For every file upload, the Assignment element’s job is to set values for variables that are needed in creating a new Content Document Link record. It then collects those values and adds them to a new collection variable (ContentDocumentLinkCollection in the screenshot below).

Once the loop is done with the last record, the Create Records element then proceeds to use the values in the new collection variable to create Content Document Link records. This isn’t a simple or straightforward example, so for full context on this use case and process, check out my deep dive on uploading multiple files via Screen Flow, where I also explain how file attachments work in Salesforce. 

Bulkifying Matters

“But I only plan to do this record update for a maximum of five records!”, you might say.

If you’re just building flows for a handful of records, I know it’s easier to take the simpler route. With no need to do assignments or make new collection variables, bulkification in the way I explained might feel like overkill. But trust me, it’s one of those things that matters before you run into problems in the future. Here’s why:

  • Limits are real: Salesforce sets limits for how many database operations you can run in a single transaction. Bulkifying ensures you don’t hit those walls.
  • It runs faster: A single update on 200 records is quicker than 200 tiny updates – otherwise, you risk what some folks call “death by a thousand cuts” (no relation to the Taylor Swift song, but it does sting just as much!).
  • Future-proofing: Your flow may only handle a few records today, but what happens when your org scales as your business grows? Five records may quietly grow to 20, and then to a hundred when the need arises. It wouldn’t be smart only to start handling limits then, right? 

So start thinking in bulk! Any time you’re about to put a Data element inside a loop, stop. Ask yourself, “Can I collect all these records and update/create/delete them once instead?” Most of the time, the answer is yes.

A Loop Is Not Always the Answer

Loops, assignments, and collections are the classic way to bulkify your flows – but they’re not the only way. And not every situation needs a loop! It’s easy to get a little trigger-happy with loops (and other elements), especially once you’ve just started to feel confident connecting and using different parts for various scenarios. I’ve been there myself: sometimes I catch myself overcomplicating a flow just because I can.

The simplest approach is usually the best. A leaner Flow means fewer elements to process in the first place, so there’s even less chance of hitting limits, and even fewer unnecessary actions overall. A good rule of thumb is to start with your entry criteria by making sure only the right records enter the flow in the first place. That way, you might not even need a loop at all! Check out this article on best practices and examples for using loops in Flow. 

Getting Familiar With the Transform Element

Now for the new kid on the block!

We’ve already talked about how loops and collections are the go-to way for bulkifying. At first glance, Transform almost feels like it was built to replace that entire pattern, and in some scenarios, it can. Especially when you’re mapping fields across objects, Transform saves you from juggling multiple assignments inside a loop.

Here’s what it does in practice:

  1. Point to your source data (say, Opportunity records).
  2. Map their fields to a target object (Cases, for example).
  3. Instantly get a new collection of variables ready to be used in a Create Records element to create Cases.

If we were to connect this to our example earlier on creating Content Document Links, here’s how the same process would look, but with a Transform element:

The Source Data column (on the left) is where you pull from. In this case, that’s a collection from a Get Records element, plus data from the created record in a Create Records element. Essentially, we’re grabbing record IDs from both. The Target Data column (on the right) is where you configure your output. I set it up as a collection of Content Document Link record variables.

Mapping is the easy part. Just click the field in the Source Data column so it highlights, then click the matching field in the Target Data column. A line appears to show the connection… and that’s it. You’ve just mapped fields without building a single assignment.

Easy, right? But here’s the important part: Transform doesn’t mean loops and collections are outdated. It’s just another tool, and besides, Transform is more than just a replacement for bulkifying with loops and collections. You can also use it for preparing data, integrations, or restructuring records for a Screen. It’s a reshaping tool, after all.

Final Thoughts

Loops and collections are reliable and valuable because once you understand them, you’ll start spotting patterns everywhere that need them. On the other hand, the Transform element is a fantastic shortcut for some scenarios that may call for bulkifying with loops and collections, but it doesn’t necessarily replace the old tools. Rather, it complements them!

So next time you’re building, don’t just think about what you’re doing. Ask yourself why you’re doing it that way, and whether another element might fit better. Of course, there isn’t always a clear-cut answer, and there’s always a whole world of factors to consider when deciding on what to use. 

Advanced Flow logic, performance tuning, and governor limits are part of that conversation – but that’s a topic for another day. For now, getting comfortable with these building blocks will put you miles ahead.

READ MORE: Mastering Salesforce Flow in 90 Days: A 12-Step Learning Plan

 

The Author

Mariel Domingo

Mariel is a Technical Content Writer at Salesforce Ben.

Leave a Reply