Loading
Salesforce now sends email only from verified domains. Read More
Automate Your Business Processes
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Loop Element

          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

          Note
          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 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.

          Field Description
          Collection Variable The collection that you want to loop through. This field accepts any collection variable.
          Direction Determines whether the flow starts with the first item or the last item in the collection variable.
          Loop Variable

          The variable that the flow uses to contain the current item’s values during a loop iteration.

          • In the resource menu, the loop variable is called Current Item from Loop.
          • If you set the loop's Collection Variable 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.
          • If you set the loop's Collection Variable 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.
           
          Loading
          Salesforce Help | Article