---
schema_version: "1"
id: ebb20bafbab559ab80c24023fe5dbf7ff35b360b7e8b31c1d46f71890f8bbbe1
title: Loop Element
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.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.flow_ref_elements_loop.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: e875c58a69eada06a00e7a4743ae5a9a1e368128578861892dff54ac739e067c
description: Start a loop path for iterating over items in a collection variable. For each iteration, the flow temporarily stores the item in the loop variable. To run actions on each item’s field values, use other elements in the loop.
products:
  - Flow Builder
  - Salesforce Platform
release: "264"
---
# Loop Element

Start a loop path for iterating over items in a collection variable. For each iteration, the flow temporarily stores the item in the loop variable. To run actions on each item’s field values, use other elements in the loop.

### 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>

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/images/icon_note.png)

Note Flow Builder remembers your expand and collapse preferences for this element on the canvas. Your view is stored locally in your browser and persists between sessions on the same browser; this setting is specific to you and does not affect the view of other users. However, if you clear your browser's cookies and other site data, or switch to a different browser, your preferences reset to the default expanded view. Clearing cached images or files doesn't affect this setting.

This video explains how a loop works in a flow that examines and runs actions on each item in a collection. The video also covers how to update or delete the evaluated data.

View this [video](https://play.vidyard.com/Q7HvTPk3pYajuMR4VJnhUw) in a separate tab.

A collection is a list of items, such as field values or email addresses. A loop uses a loop variable to store the values for the current item in the collection. When the loop finishes examining an item, the loop copies the field values for the next item into the loop variable. To reference each collection item in elements along the loop path, use the loop variable. To keep changes made along the loop path, add the loop variable as an item in a new collection variable. For example, if you're looping through contact records and have an assignment element that updates a field on the Current Item from Loop contact, save that new value before it gets overwritten by the next record's values. To save the updated record field value, after updating the field, add the Current Item from Loop record to a record collection called ContactsToUpdate. Then, after the loop, use an Update Records element to update everything in the ContactsToUpdate record collection.

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:17.825311942959%">
          <col style="width:82.174688057041%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d246177e98">Field</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d246177e101">Description</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d246177e98 ">
              <strong class="uicontrol">Collection Variable</strong>
            </td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d246177e101 ">The collection that you want to loop through. This field accepts any collection
              variable.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d246177e98 ">
              <strong class="uicontrol">Direction</strong>
            </td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d246177e101 ">Determines whether the flow starts with the first item or the last item in the
              collection variable.</td>

          </tr>
          <tr class="">
            <td data-label="Field" class="slds-cell-wrap" style="vertical-align:top;" headers="d246177e98 ">
              <strong class="uicontrol">Loop Variable</strong>
            </td>

            <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d246177e101 ">
              <p>The variable that the flow uses to contain the current item’s values during a
                loop iteration. </p>
              <ul>
                <li>In the resource menu, the loop variable is called <code>Current Item from
                      Loop</code>.</li>

                <li>If you set the loop's <strong class="uicontrol">Collection Variable</strong> to a
                  non-record collection variable, the loop variable is a variable with the same
                  data type. For example, if you have a collection of record IDs, each item is a
                  text item. So, the Current Item from Loop becomes a text variable.</li>

                <li>If you set the loop's <strong class="uicontrol">Collection Variable</strong> to a record
                  collection variable, the loop variable is a record variable with the same object
                  type. For example, if you have a collection of account records, the Current Item
                  from Loop becomes an account record variable.</li>

              </ul>
            </td>

          </tr>
        </tbody>
      </table>

- **[Simultaneously Update Fields in Multiple Records Example](https://help.salesforce.com/s/articleView?id=platform.flow_ref_elements_loop_example.htm&release=264.0.0&type=5)**  
    This example creates a flow that updates fields in multiple records by reassigning account ownership based on business rules.

#### See Also

- [_Trailhead_: Learn To Use Loops in Flow Builder](https://trailhead.salesforce.com/content/learn/modules/loops-in-flow-builder)
- [Move and Connect Elements to Change a Flow Route](https://help.salesforce.com/s/articleView?id=platform.flow_build_logic_route_add.htm&release=264.0.0&type=5 "Identify which elements the flow runs and in what order by connecting the elements on your canvas together. To change the run order, move elements and add or remove connectors.")
- [Flow Elements](https://help.salesforce.com/s/articleView?id=platform.flow_ref_elements.htm&release=264.0.0&type=5 "An element represents an action that the flow can run. Examples include reading or writing Salesforce data, displaying information and collecting data from flow users, runnning business logic, or manipulating data.")
- [Variable Resource](https://help.salesforce.com/s/articleView?id=platform.flow_ref_resources_variable.htm&release=264.0.0&type=5 "Store a value that can be used or changed throughout the flow.")