Loop Node
Last updated
Last updated
The Loop Node is a versatile control node in the Nected Workflow Editor that enables iterative processing, similar to a for loop in programming. It allows users to execute repetitive operations over a list of items with advanced configurations such as chunking and concurrency. This document provides a comprehensive guide to adding and configuring the Loop Node for your workflows.
Generally, in workflow editor, if a set of nodes require to run in loop, then there wasn’t any direct method to execute that. But the Loop Node eliminates this inefficiency by enabling iterative processing within a single workflow.
Here’s how the Loop Node simplifies iterative processing:
Iterative Execution: By looping over a list, the Loop Node processes items efficiently within defined parameters.
Parallel Processing: The Loop Node supports concurrency, enabling simultaneous processing of multiple chunks, significantly reducing execution time.
Customizable Input Handling: Users can configure chunk sizes and adjust concurrency to suit the complexity of their workflow.
To add a Loop Node to your workflow, follow these steps:
Open the Workflow editor: Go to the workflow page where your workflows are listed. Click on the workflow you want to edit. This will open the Workflow Editor.
Add Loop Node: In the Workflow Editor, locate the option to add a new node. Select the Loop Node from the list of available nodes.
You’ve now added the Loop Node to your workflow. Next, you need to configure it to suit your workflow requirements.
Once the Loop Node is added, configure it by specifying its input and execution parameters. The Loop Node uses the following key parameters:
Type: List of any data type: strings, numbers, Boolean, Date, DateTime, JSON and List.
Description: The list that the Loop Node iterates over. The loop execution depends on this input.
Example:
String List: ["A", "B", "C"]
Numeric: [1, 2, 3, 4]
List of JSON: [{"{{.globalVar.jsonVal.key_name_1}}": "{{.Trigger.Address}}"},{"{{.systemVar.ExecutionId}}": "1","{{.systemVar.Environment}}": {{.globalVar.jsonVal.key_name_2}}}]
To add input values, follow these steps:
Open the Loop node
Click on the input field which will give you two options:
Select tokens from the dropdown list
create custom List using the List editor
Type: Integer.
Description: Specifies the size of groups (chunks) processed in each iteration. The value of Chunk Size
must not be less than 1 and not exceed the size of the input list.
Example: If the Input List has 10 items and Chunk Size = 2
, the loop processes 5 iterations (2 items per iteration).
Chunk Size can’t be a minimum 1 and maximum the loop size
Type: Integer.
Description: Defines the number of concurrent processes for the Loop Node execution. This determines how many chunks can run simultaneously.
Example: If Concurrency = 3
and the Input List is divided into 5 chunks, up to 3 chunks will run concurrently.
Concurrency can’t be more than 10 and less than 1
In the Settings tab, there are 2 options:
Timeout after: This on is to set the time after which the Loop node will stop executing in case of any delay occurs in the process
Continue on error: Turning this setting on, helps the Loop node to be executed even if the node gets any error, the workflow will continue to execute the next node with the error in the output.
You can add any node inside the Loop Node to define the operations that need to be executed for each iteration. Note the following:
You can add any workflow nodes except Response Node and Delay Node.
Ensure the overall node count in the workflow does not exceed 50.
Example Workflow Inside a Loop Node:
Fetch data using an API Node.
Process the fetched data using a Custom JavaScript Node.
Save the results using a Database Node. To add nodes simply click on the + icon, and from the below dropdown list, select the required node. Like shown below:
The output of the Loop Node is an array/list containing the results of the last node executed inside the loop for all iterations.
Example Output:
Once the Loop node is added and tested, you can use the loop node output in next nodes(outside the loop node), like this:
The loopnode token looks like this {{.LoopBlock.output[0].output[0].discount}}
which you can use in the next nodes and input.
Now, if you’re using a nested loop node( one loop node inside another), then inside the child loop node, you can pass the currentItem, like this {{LoopBlock.currentItem}}
as input value.
And inside the child loop node, if you’re using any other node, then you can access both node’s current id as input value.
You can add multiple Loop Nodes sequentially in the same workflow branch.
You can add up to 2 levels of nesting in the Loop node, i.e. Inside a parent loop node, I can add a child loop node, but inside that child node, I can’t add another child loop node.
Ensure that the total number of nodes in the workflow (including all Loop Nodes) does not exceed 50.
Chunk Size Too Large
Issue: The Loop Node fails to execute because the Chunk Size exceeds the Input List size.
Solution: Ensure that the Chunk Size is less than or equal to the Input List size.
Concurrent Execution Error
Issue: Workflow performance is degraded due to high concurrency.
Solution: Adjust the Concurrency value to align with your system's processing capacity.
Input List Missing
Issue: The Loop Node cannot execute without an input list.
Solution: Verify that the Input List is correctly defined and accessible within the workflow.
The Loop Node is a powerful addition to Nected’s Workflow Editor, providing flexible and precise iterative execution capabilities. By defining parameters like Input Value, Chunk Size, and Concurrency, you can optimize your workflows for efficient and parallel processing.
Follow this guide to implement and configure the Loop Node in your workflows seamlessly. For further assistance, refer to the troubleshooting section or contact the Nected Support Team.