Introduction
Salesforce Flow has become the backbone of automation for admins and developers. It offers flexibility, scalability, and the ability to design business logic without writing Apex. However, the real power of Flow comes from how you handle collections.
Collections allow you to work with groups of records or values instead of processing them one by one. If you understand how to use them properly, you can reduce execution time, respect governor limits, and design Flows that scale across enterprise-level implementations. If used incorrectly, they become a source of inefficiency, errors, and performance bottlenecks.
What Are Collections in Salesforce Flow?

At its core, a collection in Flow is a list of items of the same type. It functions like an array in programming, but with Salesforce-specific behavior. There are two primary types:
- Record Collection Variables
- Groups of Salesforce records such as Accounts, Contacts, or Opportunities.
- Example: A query that retrieves all Contacts linked to a specific Account.
- Variable Collections
- Groups of non-record values like text strings, numbers, or IDs.
- Example: A collection of Contact IDs that can later be passed to a Flow action.
Key Point: Collections are not just containers. They control how data is stored, processed, and passed between Flow elements.
Understanding Global Search in Salesforce

1. Performance
Instead of performing updates one record at a time, collections allow bulk processing. This reduces system strain and ensures Flows run faster.
2. Scalability
Organizations with thousands of records must design for growth. Collections make it possible to handle large datasets in a single execution path.
3. Governor Limits
Salesforce enforces strict execution limits, such as:
- 100 SOQL queries per transaction
- 150 DML operations per transaction
Collections allow you to consolidate actions into fewer statements, helping you avoid hitting these limits.
4. Reliability
Collections help ensure Flows do not fail unexpectedly by controlling how data is processed in bulk rather than individually.
Common Use Cases for Collections

- Storing Results from Get Records
A query that retrieves multiple records returns them as a collection. - Processing with Loops
A loop lets you iterate through each record in a collection. - Assignments
Add or remove specific records or values within a collection. - Bulk Updates
Instead of updating inside a loop, add records to a collection and perform one “Update Records” action. - Passing Data Between Flows
Collections can be passed into subflows or actions for modular, reusable design.
Best Practices for Using Collections Correctly

1. Always Bulkify Your Flows
Collections allow you to process multiple records in a single DML statement. This is essential because Salesforce treats Flows like code. One DML per record quickly leads to limit exceptions.
Tip: Consolidate records into a single collection and perform one update.
2. Use Loops Carefully
Loops are necessary but can be dangerous when nested. Each iteration consumes CPU time and can compound errors.
- Avoid unnecessary loops.
- Keep the logic inside a loop minimal.
- Exit loops early when possible.
3. Pre-Validate Collections
An empty collection can cause runtime errors if you try to loop through it. Always check whether a collection has values before processing it.
4. Optimize Assignment Elements
Assignments allow you to add, remove, or update items in a collection. However, overusing them leads to complexity.
- Group similar operations into fewer assignments.
- Only store records that you will actually use later.
5. Respect Governor Limits
Collections are not a magic fix. You must still design with limits in mind:
- Avoid Get Records inside loops.
- Minimize unnecessary variables.
- Combine updates whenever possible.
Common Mistakes When Using Collections
- Updating Records Inside Loops
This performs one DML per record and quickly hits system limits. - Overusing Get Records
Each “Get Records” is a SOQL query. Inside a loop, this leads to limit errors. - Ignoring Null Values
Processing empty collections without validation often breaks Flows. - Unnecessary Variables
Creating multiple variables for the same purpose complicates Flow design.
Advanced Collection Strategies

1. Subflows for Modularity
Pass collections into subflows for reusable components. For example, you could create a subflow that validates Contact data, which accepts a collection of Contacts as input.
2. Filtering Collections
Large collections are sometimes retrieved, but you only need a subset. By filtering them before processing, you reduce complexity and execution time.
3. Leveraging Collection Sort and Remove Duplicates
- Sorting allows you to prioritize which records to process.
- Removing duplicates ensures you don’t perform redundant updates.
4. Integrating Collections with Apex Actions
In some cases, Flow’s visual elements are not enough. You can pass a collection into an Apex action for complex logic that Flow cannot handle efficiently.
Practical Scenarios for Collections

Scenario 1: Mass Updating Related Contacts
When an Account field changes, you need to update all related Contacts.
- Get Records: Retrieve all related Contacts into a record collection.
- Loop and Assignment: Update each Contact’s field inside the loop, then add them to an “Updated Contacts” collection.
- Update Records: Perform one bulk update.
Benefit: Only one DML operation is executed, keeping the Flow efficient.
Scenario 2: Handling Large Data Sets
A Flow retrieves hundreds of Opportunities for a single Account. Processing each individually risks hitting limits. Instead:
- Store them in a record collection.
- Perform calculations or updates in bulk.
- Commit results in one DML statement.
Benefit: Flow scales to enterprise-level volumes.
Scenario 3: Passing Data Between Teams
Imagine you build a subflow for updating addresses. Instead of designing separate Flows for Leads, Contacts, and Accounts, you pass collections of each into the same subflow.
Benefit: Reduced redundancy, modular design, easier maintenance.
Technical Considerations
- Governor Limits: Even with collections, you must design Flows to stay within Salesforce’s transaction limits. Exceeding them causes runtime errors.
- Error Handling: Always design with fault paths. Collections may contain unexpected values that need handling.
- Maintenance and Debugging: Collections can become complex in large Flows. Use naming conventions and documentation to keep them manageable.
Conclusion
Collections are not just a convenience—they are the foundation of efficient Salesforce Flow design. They allow you to bulkify operations, prevent governor limit errors, and build scalable automation that can handle enterprise workloads.
To use them correctly, follow best practices:
- Always bulkify.
- Avoid queries inside loops.
- Validate collections before looping.
- Use assignments strategically.
- Leverage subflows and filtering for modularity.
FAQ's
What Is A Collection In Salesforce Flow?
A collection in Salesforce Flow is a variable that stores multiple records or values of the same type, allowing you to handle data in bulk instead of one by one.
Why Use Collections In Flow?
Collections improve automation performance, make Flows scalable, and help avoid Salesforce governor limit errors by reducing excessive queries and updates.
How Do You Update Records With Collections?
You can loop through records, apply the necessary changes, and then bulk update them in a single step for efficiency.
Can Collections Be Used In Subflows?
Yes, collections can be passed into subflows, which makes your Flow design modular, reusable, and easier to maintain.