Skip to content
MyAppBuilder
StableAction

Repeat for each

Overview

Runs a list of actions once for every item of a list — the selected rows of a table, items stored in state, records returned by an API.

Purpose

Bulk operations from the interface: email every selected customer, create a line for each item in a cart, mark several jobs as done.

Inputs

  • For each item in — dynamic data only: a list value such as App state › items, Component › selectedRecords or an API result containing an array.
  • Do (use Event › item) — the actions to run for each item. Inside them, Event › item is the current item; in templates use {{event.item.email}}, {{event.item.id}}.

Configuration

  • Runs sequentially: each iteration finishes before the next starts, so 50 record creations take 50 round-trips.
  • Limit: at most 100 items by default (500 maximum); extra items are ignored.

Outputs

  • Results of the inner actions (last result refers to the last iteration).

Example

Create an order line per cart item

Example
Button “Place order” › On click:
  1. Create record  Orders  (Set fields: Customer = Current user › email)
  2. Repeat for each
     For each item in: App state › cart
     Do:
       Create record  Order lines
         Set fields: Order = Action results › last result id, Product = Event › item.productId, Qty = Event › item.qty

Errors

  • If an inner action fails, the loop and the remaining actions stop and an error message is shown.

Limitations

  • Processing hundreds of records is better done in a workflow (Find records + Repeat for each) where it runs on the server.

Advanced

  • Schema: { type: "loop", items: Binding, actions: Action[], max? }. The runner sets event.item for each iteration and restores the previous event afterwards; max defaults to 100, capped at 500.

Related

Was this helpful?