
A Loop is a Salesforce Flow element that is used to iterate through a number of items in a collection variable. There are three main components of a Loop: Collection Variable: This is the Collection you want to loop through – the Collection contains multiple Variables, each of which you want to either assess or action.
Table of Contents
What is a loop in Salesforce flow?
A Loop is a Salesforce Flow element that is used to iterate through a number of items in a collection variable. Collection Variable: This is the Collection you want to loop through – the Collection contains multiple Variables, each of which you want to either assess or action.
What are Salesforce flows?
Salesforce Flows are a way to automate processes using a point and click interface without the need for code. With each Salesforce release, Salesforce Flows get better with new and exciting features being added.
How do you loop through a collection in Salesforce?
Now that you have your Collection, it’s time to loop through the records and change the Active field, according to the Account’s new value. To do this, create a Loop after the Get Records element. Use the Collection that was created in the Get Records element.
What should I avoid when creating a loop in Salesforce?
One thing you should try to avoid is putting any Get Records, Create Records, Delete Records or Update Records steps inside the “For Each” part of your loop. This is a good way to run into trouble with Salesforce’s limits. This is often shortened to “no pink elements inside a loop”.

How do you end a loop in flow?
Use the Exit Loop action inside a Loop action to terminate the current loop iteration, leave the loop action, and continue the flow execution by moving to the following action. The Exit Loop action is located in the task editor Toolbox.
What triggers a flow in Salesforce?
Creating or updating a record can trigger an autolaunched flow to make additional updates to that record before it’s saved to the database. A record-triggered flow can update a Salesforce record 10 times faster than a record-change process.
What can Salesforce flows do?
Flows can look up, create, update, and delete Salesforce records. They can also create Chatter posts, submit records for approval, and send emails. If your action isn’t possible out of the box, call Apex code from the flow. Connect your flow to an external database by using core actions or Apex actions.
How many records can a Salesforce flow handle?
Required EditionsPer-Transaction Limit1ValueTotal number of DML statements issued (Create Records, Update Records, and Delete Records executions)150Total number of records processed as a result of DML statements10,000Maximum CPU time on the Salesforce servers10,000 milliseconds3 more rows
Can a workflow trigger a flow?
Create a flow trigger workflow action to launch a flow from workflow rules. With flow triggers, you can automate complex business processes—create flows to perform logic, and have events trigger the flows via workflow rules—without writing code.
What is $record in flow Salesforce?
In a record-triggered flow, the $Record global variable contains the triggering record’s values. You can reference and change $Record values throughout the flow. If the flow runs before the record is saved to the database, Salesforce automatically applies any changed $Record values to the record in the database.
Is flow faster than process builder?
Because of the additional DML in Process Builder, the time consumed can significantly increase based on the automation setup in the org. And this is one of the most important reason why Before-save Flows are way more performant than Process Builder.
Is flow better than process builder?
With recent updates, everything you can do in Process Builder can also be done in Flow Builder—but Process Builder is a lot simpler and easier to use. So, Process Builder is generally a good way to introduce simple automations, while Flow Builder is a better choice for more complex automations.
Why flows are better than process builder?
Flow also takes up a lot less processing time than Process Builder (depending on how you build them) so it should be taken into consideration if you are building multi-node process builders. If you have a background in technology and have dabbled with code before, the logic of Flow tends to make more sense.
How many records can be updated in a flow?
Quick Action elements can update only one record at a time, while Update Records elements can update multiple records.
How do I create a loop variable in Salesforce?
Scenario 1 – Repeat By Loop ElementStep 1 – Create a collection variable. First you need to have a collection variable. … Step 2 – Put in the Loop element. … Step 3 – Add actions inside the loop. … Step 4 – IMPORTANT! … Step 5 – Add actions after the loop is done.
How many flows can I run per month Salesforce?
Your Salesforce edition limits how many flows you can create. Essentials and Professional editions of have a limit of five processes (per process type) and flows (per flow type) in each organization. For most logic in these editions, it is easier to use a process.
What is a Loop in Salesforce Flow?
A Loop is a Salesforce Flow element that is used to iterate through a number of items in a collection variable.
How to Create and Use a Loop
Let’s use this scenario: An Account has an Active__c Checkbox field, as does the Contact object. Your manager has asked you to create a Flow that marks all child Contact records as Active or Inactive, based on the value of the Account’s field.
Best Practices When Using Loops in Salesforce Flow
While creating the above Flow, we’ve already discussed some best practices that need to be taken into account while using Loops in Salesforce Flows. Let’s reiterate and go into further detail:
Summary and Further Learning
In the above example, you learned how to use Loops in a Flow and also some key best practices to keep in mind, when using Loops. If you’d like to learn more about using Loops and using Flows in general, there’s a few options I’d recommend.
Top Tips for Salesforce Flows
When building Flows, I stick to a set of rules that are inspired by Salesforce best practice:
Some real-life Flowspiriation
From my own experience I’ve seen the good, the bad and the ugly when it comes to Flows. Here are some of my top picks of the good:
Summary
Like all systems, there are limitations with Flows such as issues with Owner fields on Screen Flows and difficulties with parsing Multi-Select Picklist Values that it would be nice for Salesforce to resolve longer term.

What Is A loop?
But First, What’s A Collection?
-
Flow calls lists of things “collections”. It’s a complicated name for a simple concept. Whenever you see the word “collection” in the Flow Builder, just think “list”. Remember, a loop is all about doing some stuff for eachthing in a list. We call this “looping over” or “looping through” a collection. So naturally, loops in Flow are pretty tied to collections. In fact, you can’t use a loop if …
A (Weird) Word of Caution
-
With great power comes great responsibility. One thing you should try to avoid is putting any Get Records, Create Records, Delete Records or Update Records steps inside the “For Each” part of your loop. This is a good way to run into trouble with Salesforce’s limits. This is often shortened to “no pink elements inside a loop”. All of Flow’s data elements are pink and so if you see one insid…
Where to Go from Here
-
Loops are something we do every day in our work without even really thinking about it. They’re also one of the things that makes Flow much more powerful than Process Builder. Plus, they’re not as complicated as they first seem. Don’t be afraid to use them. Here are some times to consider using loops: 1. Batch processes that need to make a change each item in a list of recor…