# Loop For Module

* [Definition](#definition)
* [Configuring the Loop For module](#configuring-the-loop-for-module)
  * [Loop For](#loop-for)
  * [Example](#example)

### Definition <a href="#definition" id="definition"></a>

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 `element` from the code above in Skyone Studio, the **Begin** operation of the **For** module initializes and maintains 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

{% hint style="info" %}
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).
{% endhint %}

### Configuring the Loop For module <a href="#configuring-the-loop-for-module" id="configuring-the-loop-for-module"></a>

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:

<figure><img src="/files/EJVeSNuocL1bCdGbopgT" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
[Find out about the Module Header here](/english/skyone-studio/integrations/flows/module-header.md).
{% endhint %}

#### **Loop For** <a href="#loop-for" id="loop-for"></a>

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**.

<figure><img src="/files/AfxIafSXg9B7XghmEbci" alt=""><figcaption></figcaption></figure>

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

#### Example

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

<figure><img src="/files/HsiVfBRtWKBjPkK4Qd8n" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.skyone.cloud/english/skyone-studio/integrations/flows/tool-modules/loop-for-module.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
