---
schema_version: "1"
id: a1a4976a5c0eb184c2aa6b4fb81c3cff3b5ed397acd922e16237474a2f64a927
title: Simultaneously Update Fields in Multiple Records Example
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/flow_ref_elements_loop_example.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.flow_ref_elements_loop_example.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: f8638611647f0019f403e50efd145b3e12c035a12471dbb4fc1aa612ad8b7a46
description: This example creates a flow that updates fields in multiple records by reassigning account ownership based on business rules.
products:
  - Flow Builder
  - Salesforce Platform
release: "264"
---
# Simultaneously Update Fields in Multiple Records Example

This example creates a flow that updates fields in multiple records by reassigning account ownership based on business rules.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;"><a href="https://help.salesforce.com/s/articleView?id=platform.flow_ref_supported_editions.htm&amp;release=264.0.0&amp;type=5" title="Learn about the editions and user interfaces that support Flow Builder. Some Flow Builder features integrate with other Salesforce products that require additional licenses.">View supported editions.</a></td></tr></tbody></table>

![Example of a flow that loops through a collection](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/process_collection_loop.png)

First, create an Account-based record collection variable called `collReassignedAccts`.

![New Resource window shows Resource Type set to Variable, API Name set to collReassignedAccts, Data Type set to Record, Allow multipile values (collection) selected, and Object set to Account](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_loop_example_coll_var.png)

Next, add the Get Records element to get all account records that John Smith owns.

![Get Records element that shows condition requirements for OwnerId equal to John Smith's ID and How Many Records to Store set to All Records](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_loop_example_get_records.png)

Then create a loop that iterates through the collection. For each item in the collection, the loop:

1. Assigns the collection item to the loop variable.
    
    ![Loop element that shows the collection variable set to Accounts from John's Accounts](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_loop_example_loop.png)
2. Evaluates whether the account has more than 10,000 employees.
    
    ![Decision element that shows the condition requirements for the Yes outcome, where the resource is set to the Employees field on the current item in the loop, the Greater Than operator, and for Value, 10000](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_loop_example_decision.png)
3. If the account has more than 10,000 employees, assigns Madison's user ID to the **OwnerId** field in the loop variable.
    
    ![Assignment element that shows the variable set to the current item in the loop with the Equals operator and for Value, Madison's owner ID](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_loop_example_assign_madison.png)
4. If the account doesn't have more than 10,000 employees, assigns Amber's user ID to the **OwnerId** field in the loop variable.
    
    ![Assignment element that shows the variable set to the current item in the loop with the Equals operator and for Value, Amber's owner ID](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_loop_example_assign_amber.png)
5. Adds the loop variable's values as a new item in the `collReassignedAccts` collection.
    
    ![Assignment element that shows the collReassignedAccts variable with the Add operator and for Value, the current item from the loop](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_loop_example_assign_new_accts.png)
6. Finally, add an Update Records element to update the accounts in `collReassignedAccts` with the new **OwnerId** after the loop finishes iterating through the collection.
    
    ![Update Records element that shows the collection variable set to the collReassignedAccts](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/platform_automation/images/flow/flow_loop_example_update_records.png)
    
    This section of the flow uses a single query to look up the list of accounts and a single DML statement to update those accounts. If you updated the records by setting the fields individually, you would use:
    
    One Update Records element to find all accounts that John owns and have more than 10,000 employees (1 query). Then update those records’ **OwnerId** to Madison’s Id (1 DML statement).
    
    One Update Records element to find all accounts that John owns and don’t have more than 10,000 employees (1 query). Then update those records’ **OwnerId** to Amber’s Id (1 DML statement).