Loop

The Loop tool allows you to iterate over a list of items one-by-one.

A Loop is useful when you want to take a list of things, for example, all of the line items in an order, and perform an action on each individual item.

Configure

Loop

To iterate over specific items from a list (typically from the Triggerarrow-up-right or Actionsarrow-up-right), use the variablesarrow-up-right menu to select the list of items after adding your Loop step.

After your Loop has been added and configured, you'll see your Loop steps within a confined container with a grey border.

To perform one or more tasks on each item in the list, add actionsarrow-up-right after the Loop within the container with a grey border.

You can reference the individual items or their information by using the Loop variables that will populate for actions added in the Loop container.

You will have variables available from steps that occur prior to the Loop in your workflow, as well as the Loop variables. Typically, you'll want to use Loop variables when configuring actions within the Loop container.

circle-info

Be sure to Save your workflow after adding and configuring your Loop to see your available Loop variables.

In each Loop action, there are conditions you can add to filter the list.

You can populate the Filter by conditionsarrow-up-right via the More fields button so that specific values or results that meet the conditions are passed to the following steps.

Going Further

Loop End

The default configuration of the Loop tool will continue the workflow without passing variables after the Loop. However, you can optionally configure a Loop End step to build a list from matching items to use in later steps.

In the Loop step, click the More options button to add the Loop End via the Build a list from matching items checkbox.

After saving your workflow, use the variablearrow-up-right selector to append data from the Loop container to use in future steps after the Loop.

The value can be a single variable from an action within the Loop, or you can add a Transform Mappingarrow-up-right action within the Loop and map a new object.

The variable that's created from the Loop End step will be Loop End > Items, and it can be used in steps after the Loop.

Other kinds of Loop steps

Beyond the regular Loop action, you can add different variations of Loop actions to your workflow. These are single-output steps with a different behavior than the Loop & Loop End functionality.

Sum

The Loop Sum action will calculate the sum of all items that match a specific criteria.

For example, the Loop Sum action can add up the price of line items (products) in an order and pass that value as a variable to reference in the following steps. The value will be an integer.

Map

The Loop Map action will create a list of values that are identified based on the item you're referencing from a previous step.

For example, the Loop Map action can pass all line item (product) titles in an order for tagging purposes.

Number of Matches

The Loop Number of Matches action will return the number of items that match a specific criteria.

For example, the Loop Number of Matches action can provide an integer as a variable that can be referenced in future steps representing the number of line items (products) in an order with a specific SKU.

Technical Notes

  • The Loop queue is synchronous.

  • There is a legacy version of the Loop step that can be found on stores with previous versions of MESA, or when using templates that have not been updated to the latest Loop and Loop End functionality.

    • Everything gets enqueued all at once with legacy Loop actions, which makes this action more susceptible to timeouts.

Last updated