The Loop Node in Cobalt allows users to iterate over entities or execute a series of actions for a fixed number of iterations.

Node Functionality

Loop node is like a repetitive steps executor within the workflow. It can:

  • Wrap around other nodes and execute them repetitively;
  • Use the data received from all iterations of the Loop node in other nodes of workflow. Refer here;
  • Execute nodes for fixed number of times using Fixed Iteration;
  • Execute as many times as there are items in an array using Array Iteration; &
  • Execute nodes repetitively based on case and break conditions using Do While;

To incorporate repetitive actions or iterate over arrays within a workflow, users simply place the desired action nodes inside the Loop Node and provide values for the input fields based on their requirements.

Actions

The Loop Node offers three distinct actions to choose from:

Iterating Array

Fixed Iteration

Do While

Input Fields

The input fields for the Loop Node vary based on the selected action. In case of Array Iteration , you need to provide the array which will determine the no. of times the loop will be executed while in Fixed iteration, you simply provide the Number of Iterations.

Group Node output

This is only available in Array Iteration and Fixed Iteration action of the Loop Node.

The Output Data field lets you store specific data from each iteration and use it outside the loop once all iterations are complete.

This field is optional and supports templating, allowing you to reference data from any node inside the loop.

For example, in the picture above, we are calling NetSuite API to get Contact by ID in a loop and adding the response that we receive in each iteration in the Loop node by templating the response of that node.

At the end of all iterations, the node outputs an array containing the values from each loop cycle and can be accessed in other nodes using the templating:

{{node.<loop_node_number>.body}}.

In the picture below, we are using the data that we received from the Loop node by templating it.

Templating items inside Loop Node

To access the array item that is being passed in the Loop Node, within any node for each iteration, it can be done so by calling array_item object. Consider you want to access an Id that is unique within each array item that is being passed in the Loop Node. To do so, do the following templating

{{node.<node_no.>.body.array_item.Id}}

When using Do While action, you might need to access the iteration count of the loop within the workflow. This can be accessed as

{{node.<no. of loop node>.body.iteration_count}}

To know more about Templating in Cobalt, refer to our doc here.