Skip to main content

Loops

Most real records contain lists — an order has line items, an invoice has rows. A loop maps each item in a source list to an item in a target list.

How a loop is defined​

SettingWhat it does
FromThe source list to iterate over (e.g. line_items).
TargetThe target list to produce (e.g. items[]).
FilterOptional conditions to decide which items to include.
FieldsThe field mappings applied to each item in the list.

The field mappings inside a loop work exactly like top-level field mappings — same modes, transforms, and type casting — but they run once per item.

Filtering items​

A filter lets you include only some items. You add one or more conditions and join them with AND or OR:

  • AND — an item is included only if all conditions match.
  • OR — an item is included if any condition matches.

For example, include only line items whose quantity is greater than zero.

Example​

Source:

{
"line_items": [
{ "sku": "ABC-1", "quantity": 2, "price": "19.99" },
{ "sku": "XYZ-9", "quantity": 0, "price": "5.00" }
]
}

Loop: line_items → items[], filter quantity > 0, mapping sku → itemId and casting price to a number.

Output:

{
"items": [
{ "itemId": "ABC-1", "quantity": 2, "price": 19.99 }
]
}

The second line item is dropped because it failed the filter.

tip

Build the loop's per-item fields the same way you'd build a single record, then let the loop apply them across the whole list.