Skip to content

Run Parallel Iteration for a Collection v1.0.6 Help

Starts an iteration in parallel threads to loop over a JavaScript/JSON object or array.

How can I use the Step?

The Step lets you process elements of a JavaScript/JSON array or object concurrently, enhancing the throughput of your workflow. This can be useful for accelerating tasks such as data aggregation, customer record management, and workflow automation.

How does the Step work?

The Step loops over the first dimension of input data in parallel and has three main exits:

  • new thread: Defines the iteration logic. It must conclude with the End Thread and Return Result Step to indicate the end of the iteration and return the Flow to the Step.
  • results: Triggered after loop completion, allowing the Flow to proceed to subsequent Steps.
  • error: Raises error and stops the Step execution. Triggered when the input data is invalid.

To form a loop, place End Thread and Return Result Step down the new thread exit after the iteration logic. Run Parallel Iteration for a Collection Step must not be the first Step in the Flow.

Caution: Some Steps might produce unexpected errors in parallel threads. In such cases, retry the Step or consider using a regular iteration loop.

Handling multidimensional data

To handle multidimensional data using this Step, you have several options:

  • Parallel within Parallel: Nest one parallel loop within another. However, transferring data using the Result field is not guaranteed for this option.
  • Parallel within Regular: Nest parallel loop within a regular iteration loop, which you can form using a pair of Start Iteration and End Iteration Steps.
  • Regular within Parallel: Place a regular iteration loop inside a parallel one.

Prerequisites

To use the Step, ensure the following prerequisites:

  • Basic knowledge of JavaScript/JSON.
  • End Thread and Return Result Step must be placed down the new thread exit after the iteration logic.

Input data

  • For Source, provide the input data for iteration. It must be a JavaScript/JSON object or array. This parameter is required.

Merge field settings

  • For Output data structure, define the iteratedItemValue property structure to access specific source properties from the subsequent Steps in the new thread exit.

The Step returns the output as a JSON array/object and stores it under the Merge field name. The Merge field type defaults to thread.

To learn more about Merge fields and how to work with them, see our Merge fields guide.

Output example

The output depends on iteration progress and includes the following properties:

During iteration:

  • iteratedItemValue: The current iterated value.
  • iteratedItemKey: The current index for an array or key for an object.
  • iteratedIndex: The number of the current iteration, starting from 0.

After iteration:

  • result: an array or object with the same number of items as the iterated source. By default, each item value is an empty string. To return specific data for each iteration, use the Result parameter in the End Thread and Return Result Step.

For example, if you iterate through the array of items ["apple", "banana", "cherry"], using the Result parameter to return a length of each item, the Step output is:

json
{
  "result": [5, 6, 6]
}
{
  "result": [5, 6, 6]
}

Error handling

By default, the Step handles errors using a separate exit. If the source data is neither an array nor an object, the Step throws an error, and the Flow proceeds down the error exit.

For more information, see Error and timeout handling.

Reporting

The Step automatically generates Reporting events during its execution, allowing for real-time tracking and analysis of its performance and user interactions.

To learn more, see Reporting events.

Service dependencies

  • studio v3.71.0
  • bot deployer v2.22.4
  • library v2.18.4

Release notes

v1.0.6

  • Initial release