Loop Data – Iterate through columns of data, counters, Google Sheets, variables, tables, custom data, or other elements.
Loop Element – Iterate through elements on a web page.
Repeat Task – Perform an action repeatedly for a specified number of times.
There are several ways to implement loops in automation:
Looping allows you to repeatedly perform the same action until all data has been processed. It is particularly useful when handling multiple similar items, such as filling out forms with values from Google Sheets.
Using Loop Data Nodes or Loop Element Nodes
When using Loop Data or Loop Element nodes, it is essential to include a Loop Exit node in the process. The Loop Exit node defines the boundary of the loop, ensuring that the script knows when to stop iterating.
Inside the Loop Exit node, you must specify the Loop ID that corresponds to the loop node you are using. This ensures that the loop functions correctly and exits at the right point.
Loop Execution and Data Access in Automation
In the above process, the script executes a Mouse Click node and loads content for each iteration of the data loop. The number of loop iterations depends on the user's specified count. After looping through all the data, the script proceeds to execute a Mouse Move node.
If the loop does not have a defined boundary using a Loop Exit node, it will not function correctly.
Accessing Elements Within a Loop
You can use the expression {{loopData.loopId}} to access data from the current iteration within the loop's scope.
Example:
Replace loopId with the actual Loop ID specified in the Loop Data node to retrieve the name value during iteration. This value can then be used in other nodes, such as the Keyboard Press node.
Return Format of {{loopData.loop}}
{
"data": ...,
"$index": 1
}
Therefore, if you want to access the loop sequence of that iteration, you can use expressions such as {{loopData.loopId.$index}}.
To retrieve loop values, you do not need to write data explicitly in expressions like {{loopId.loopId.data}}, as Automation automatically assigns it to the expression.
However, if you use a JavaScript expression, you must include the data property, such as !!{{loopData.loopId.data}}.
Using the Repeat Task Node
Using the Repeat Task node is the simplest way to perform repetitions. You only need to specify the number of times the action should be repeated and define the starting point where the action should be repeated.
Example:
The process below will execute a Get Text node and then repeat that node two more times before proceeding to the next node.