You can use looping to perform the same actions several times. It stops only after all the items have been looped.

The loop is useful when you want to process several similar elements, such as completing forms that values come from a Google sheet. You can use several methods of looping in GoLess:

  1. The Loop Data blocks can be used to loop through a table, Google spreadsheet, variable, or custom JSON Array.

  2. The Loop Elements block can be used to loop through elements on one page.

  3. The Repeat Task block can be used for frequently repeating actions a specified number of times.

Working with the Loop Data or Loop Elements Block

The Loop Break point must be included in the workflow when using the Loop Data or Loop Elements block. The Loop Break point lets you tell the workflow where the loop reach is. Also, inside the Loop Break point, you have to enter the loop block's loop ID.

The workflow above will constantly run the Forms and the Get Text block depending on the number of elements. After all elements are looped, the workflow moves to the Export Data block.

If you don't set the loop range using the Loop Break point block, the loop won't work.

The above example will run the Forms and the Get Text block one time and move on to the Export Data block.

Access Loop Item

Expressions can be used to access data from the current loop iteration inside the loop range. For instance, replace the loopId with the Loop id you inputted inside the Loop Data or Loop Element block: {{loopData.loopId}}.

The {{loopData.loopId}} expression will return:

  "data": ...,
  "$index": 1

To sum it up, if you need to access the loop index, you can use expressions like{{loopData.loopId.$index}}. To get the loop value, you don't need to enter the data property like {{loopId.loopId.data}}, GoLess will automatically set it to the expressions. However, for JavaScript expressions, you should include the data property !!{{loopData.loopId.data}}

Usage of the Repeat Task Block

The Repeat Task block is the simplest way to make a loop. Simply define how often to repeat the actions and where to start repeating them.

The above example will repeat executing the Click Element block three times. After that, the workflow will continue to the New Tab block.

Last updated