How do I iterate over line items or map a field value to multiple fields in one automation rule?
Last updated: August 25, 2026
Advanced Automation Actions: For-Each and Lookup-and-Update
Two power actions let you handle per-line-item logic and multi-field value mapping without creating dozens of separate rules.
For-Each: act on individual line items
The for-each action iterates over every line item on an order and runs a nested set of actions only on the items that satisfy an inner condition.
Common use cases
Zero out the quantity of any line item that does not have enough stock.
Create an assembly order for each line item whose SKU ends with a specific suffix.
Set an estimated ship date on pre-order line items identified by a custom field value.
How it works
Add a For Each action to your rule.
Choose the collection to iterate — typically order line items.
Optionally add inner conditions (e.g. SKU starts with "CUSTOM-", Insufficient Stock). Only items that match ALL inner conditions receive the nested actions.
Add one or more nested actions that run per item. Inside these actions you can reference the current item's fields (e.g.
{{ item.sku }},{{ item.quantity }}).
Notes
If one item's nested action fails, the loop continues processing the remaining items.
The
Insufficient StockandBOM Stock Availabilityconditions are designed specifically for use inside a for-each loop.
Lookup-and-Update: map one value to many field updates
The lookup-and-update action reads a field on the order, looks it up in an inline mapping table you define, and then updates multiple fields with the matched values — all in a single action step.
Common use cases
Map a facility ID custom field to the corresponding ship-to address (street, city, state, postal code, country).
Map a requested shipping method to a carrier code and service code.
Map a warehouse code to a warehouse name and phone number.
How it works
Add a Lookup and Update action.
Set the key field — the field on the order whose value will be looked up (supports regular fields, custom fields, and dot-notation relationships).
Set the default behavior — skip (do nothing if the key is not found) or error (stop the rule).
Define your mapping table: each entry maps one key value to one or more field updates.
Example — facility ID to address
Facility ID | Updates applied |
|---|---|
FAC001 | Ship-to address → 123 Main St, New York, NY 10001 |
FAC002 | Ship-to address → 456 Oak Ave, Los Angeles, CA 90001 |
A mapping with 100+ entries replaces 100 separate automation rules.
Key matching notes
Matching is exact and case-sensitive.
Leading/trailing whitespace is trimmed automatically.
Numeric key values (e.g.
42) match the string key"42".