Docs Menu
User Guide / Control Structures / ForEach

ForEach Step

We already know that looping in programming languages is a feature that facilitates the execution of a set of instructions/functions repeatedly while some condition evaluates to true. Syncloop API Development Platform provides looping control structures also. These ForEach steps are used to traverse through the lists that as specified as Input Lists and iterate till the end of the list is not reached. Any variable can be converted into an array by clicking on the array property in the properties option of the variable/element. To create a new ForEach Step right click on the workspace, an API Designer context menu will be displayed, click on ForEach.

Properties of ForEach

Properties of ForEach

Right Click on the ForEach and select properties, the properties dialog will be displayed.

ForEach Block

It has six main properties

Status: To enable/disable the ForEach Block. The default status will be in enabled mode. If the status is selected as disabled in the case switch & its child cases and further steps will not execute when the API service will be invoked either from HTTP or from another service.
Snapshot: Create a runtime data state snapshot for the ForEach step.
Comment: Add comment to the ForEach Block.
Input List: The input list (in the form of the array) will be given as input. The value of the input list will be the XPath of the variable. The ForEach will always work on the input list and will traverse each element of the list (Array). This array is specified as the input parameter.
Output List: The output list (in the form of the array) will be generated from the input list. The value of the output list will be the XPath of the variable and is specified as the output parameter. The only consideration that has to be kept there is that the list/array should not have existed before in the service or else this will create a conflict.
Type: This describes the type of the list. This list type will be applicable to Input List. This type can include Document, Object, String, Integer, Boolean, Number, Byte, and Date.