Loop

Go over each element in a collection and do something with it.

When to use?

If you have an array of items, or any other collection that can be traversed, and you want to perform an operation with each item, use this element.

How to use:

  1. Make sure you've got an indexed array obtained with e.g. an Http Client, a Json Reader, or set manually with Set Parameter.
  2. In the Items field, enter the name of the array wrapped in the expression syntax, for example ${array_name}
  3. In the Data Collection Item Name enter the name under which you'll be able to access individual array items, for example: item.
  4. You can skip iterations of as many items as you wish, starting from the beginning of the array, by entering an offset number in the Offset field
  5. Entering a limit number in the Limit field limits the loop to the specified number of iterations
  6. You can place any number of other elements inside the Loop element
  7. In the Loop Until field, enter the expression which will be true to exit the loop.

Example of usage:

Suppose you have an array of players, imaginatively called players, and each player has a score. Here is an example showing how you could output each player's score:

Status variable fields

Fields for property Data Collection Item Name
Field Description
value The current value of the collection being iterated over
index Current programmatic index of the loop (starts at 0)
natural Human readable index (starts at 1)
first Boolean flag, whether the item is first in the collection
last Same as first, only checks if the item is last