GoLess
  • Basics
    • Recording Actions
    • Adding workflow manually
    • Tutorial: Scraping data
  • Workflow
    • Customization
    • Blocks
    • Global Data
    • Variables
    • Element Selector
    • Expressions
    • Workflow Table
    • Looping
    • Google Drive
  • Blocks
    • General
      • Note Block
      • Trigger Block
      • Execute Workflow Block
      • Delay Block
      • Export Data Block
      • HTTP Request Block
      • Blocks Group
      • Clipboard Block
      • Wait Connections Block
      • Notification Block
      • Workflow State
      • Parameter Prompt Block
    • Browser
      • Active Tab Block
      • New Tab Block
      • Switch Tab Block
      • New Window Block
      • Proxy Block
      • Go Back Block
      • Go Forward Block
      • Close Tab/Window Block
      • Take Screenshot Block
      • Browser Event Block
      • Handle Download Block
      • Handle Dialog Block
      • Reload Tab Block
      • Get Tab URL Block
      • Cookie Block
    • Web Interaction
      • Click Element Block
      • Get Text Block
      • Scroll Element Block
      • Link Block
      • Attribute Value Block
      • Forms Block
      • Javascript Code Block
      • Trigger Event Block
      • Switch Frame Block
      • Upload File Block
      • Hover Element Block
      • Save Assets Block
      • Press Key Block
      • Create Element Block
    • Control Flow
      • Repeat Task Block
      • Conditions Block
      • Element Exists Block
      • While Loop Block
      • Loop Data Block
      • Loop Elements Block
      • Loop Breakpoint
    • Data
      • Insert Data Block
      • Delete Data Block
      • Get Log Data Block
      • Slice Variable Block
      • Increase Variable Block
      • RegEx Variable Block
      • Data Mapping Block
      • Sort Data Block
    • Оnline Services
      • Google Sheets Block
    • Premium
      • ChatGPT Block
      • Captcha Block
  • REFERENCE
    • Logs
    • Schedule
    • Storage
    • Packages
    • Condition Builder
    • Workflow Common Errors
    • JavaScript Execution Context
Powered by GitBook
On this page
  • Working with the Loop Data or Loop Elements Block
  • Access Loop Item
  • Usage of the Repeat Task Block
  1. Workflow

Looping

PreviousWorkflow TableNextGoogle Drive

Last updated 1 year ago

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.

Loop with breakpoint

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.

Loop without breakpoint
Access loop item
Repeat task