---
title: "For Of"
description: "Run the body for each item in a list."
canonical_url: "https://docs.vettero.com/build/workflows/blocks/loops/for-of"
---
# For Of

> Run the body for each item in a list.

<block-meta block="Yes" channels="Any" folder="basic/loops" group="Loops" groupTo="/build/workflows/blocks/loops" icon="i-lucide-list-ordered" pipe="Value" scope="Any" tool="No" type="loop.for-of">



</block-meta>

**For Of** walks a **list** and runs the **callback** body once per item. After the last item, the main path continues and the pipe holds every value the body **return**ed.

Use [For In](https://docs.vettero.com/build/workflows/blocks/loops/for-in) for object keys. Use [For](https://docs.vettero.com/build/workflows/blocks/loops/for) for a numeric range.

## Configure

<table>
<thead>
  <tr>
    <th>
      Setting
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        Array
      </strong>
    </td>
    
    <td>
      Context path to the list (<code>
        args.*
      </code>
      
      , <code>
        pipe.*
      </code>
      
      , named variables). Must be a list
    </td>
  </tr>
</tbody>
</table>

The **Callback** outlet must be connected to a [Lambda](https://docs.vettero.com/build/workflows/blocks/module/lambda) block. If it is not connected, the run fails.

## Handles

<table>
<thead>
  <tr>
    <th>
      Handle
    </th>
    
    <th>
      Role
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        In
      </strong>
      
       (target)
    </td>
    
    <td>
      Incoming connection
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Out
      </strong>
      
       (source)
    </td>
    
    <td>
      Continues after the loop finishes (main path, same scope)
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Callback
      </strong>
    </td>
    
    <td>
      <strong>
        New callback scope
      </strong>
      
       for each item. Connect to <a href="https://docs.vettero.com/build/workflows/blocks/module/lambda">
        Lambda
      </a>
    </td>
  </tr>
</tbody>
</table>

Inside the body (after Lambda), use:

<table>
<thead>
  <tr>
    <th>
      Path
    </th>
    
    <th>
      Meaning
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        args.index
      </code>
    </td>
    
    <td>
      Zero-based position in the list
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        args.item
      </code>
    </td>
    
    <td>
      Current item
    </td>
  </tr>
</tbody>
</table>

End the body with a **return**. That returns from this callback, not from the whole workflow. The value is stored for this item. [Continue](https://docs.vettero.com/build/workflows/blocks/loops/continue) skips the rest of this item. [Break](https://docs.vettero.com/build/workflows/blocks/loops/break) stops remaining items. An unconnected **Out** ends the main path after the loop.

## Pipe schema

The next block on the main path reads this on the data pipe (`pipe.value`).

<table>
<thead>
  <tr>
    <th>
      Field
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      Results
    </td>
    
    <td>
      list
    </td>
    
    <td>
      Values <strong>
        return
      </strong>
      
      ed for each item, in list order
    </td>
  </tr>
</tbody>
</table>

## Use case

- Process each row from a query, each id from arguments, or each file from an upload list.
- Inside the body, branch with a [condition](https://docs.vettero.com/build/workflows/blocks/condition) and **return** a mapped value to collect on the pipe.
- Skip an item with [Continue](https://docs.vettero.com/build/workflows/blocks/loops/continue), or stop early with [Break](https://docs.vettero.com/build/workflows/blocks/loops/break) when you only need the first match.

<block-page-nav>



</block-page-nav>


## Sitemap

See the full [sitemap](https://docs.vettero.com/sitemap.md) for all pages.
