Loop For Module

Definition

The "Loop For" tool module, a default module to be used in any flow, was created to meet the need for processing data lists. It consists of two operations, Begin and End, which mark, respectively, the beginning and the end of a loop, based on an array that you must provide in JSON format.

The first operation (Begin) only takes as argument a list or array and derives the 3 FOR statements from that list. This type of statement is also known as For Each in some languages, and can be represented as follows:

for(loop_counter = 0; loop_counter < array.length ; loop_counter++){
    element = array[loop_counter]; 
	//bloco de código que será executado
} 

To represent the loop_counter and the above code element in the platform, the Begin operation from the For module initializes and holds two equivalent parameters, which can be accessed by any module connected to the flow:

  1. loopCounter: stores the flow execution position, starting from the value "0" for the first execution and increasing it with each execution

  2. element: stores the array element that is in the loopCounter position, and it is a convenient way to access the contents of each loop execution

The Begin operation of the For module will only execute the code within the flow block located between the For Begin and For End operations if the array passed as parameter is valid. If the array is empty (i.e., only "[]"), the entire block will be ignored and the execution will either move on to the next flow component after For End or simply terminate the flow execution (if there are no more operations to execute).

Configuring the Loop For module

The "Loop For" module appears in the Tools option of editing a flow. Right after the click to add it, opens the modal for configuration:

Loop For

Fill in the required Loop For fields, where:

  • List (Array): here you can either drag a parameter from the previous operations or a flow parameter, as well as manually enter an array or create an SMOP operation ( icon);

  • Validate: validates the array, displaying the complete list that will be handled in the Data Preview area.

To finish configuring the module, click on "Save".

Example

The "Loop For" module requires another module to be connected to it. See the example:

Last updated