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

  1. Add a For Each action to your rule.
  2. Choose the collection to iterate — typically order line items.
  3. Optionally add inner conditions (e.g. SKU starts with "CUSTOM-", Insufficient Stock). Only items that match ALL inner conditions receive the nested actions.
  4. 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 Stock and BOM Stock Availability conditions 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

  1. Add a Lookup and Update action.
  2. Set the key field — the field on the order whose value will be looked up (supports regular fields, custom fields, and dot-notation relationships).
  3. Set the default behavior — skip (do nothing if the key is not found) or error (stop the rule).
  4. Define your mapping table: each entry maps one key value to one or more field updates.

Example — facility ID to address

Facility IDUpdates applied
FAC001Ship-to address → 123 Main St, New York, NY 10001
FAC002Ship-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".