Collect loop results
  • 14 Apr 2024
  • 1 Minute to read
  • Dark
    Light

Collect loop results

  • Dark
    Light

Article Summary

The Collect operator enables you to gather the results of a loop's iterations into a single array, simplifying the reference of the results in subsequent steps.

Important notes
  • The Collect operator can only be placed and used within a loop.
  • The operator shouldn't be used to collect more than 1MB of data.
  • Each loop iteration clears the results array so that only the current iteration's results are collected. To collect all results in a single array, you should use additional Collect operators in the parent loop.

Flatten results

Flatten results is an optional parameter in the Collect operator. Set the Flatten Results toggle to Yes to merge the inputs (iteration results) into a single array. This can be useful for paginated results. By default, every iteration result will create a new item in the loop results array.

How to use

  1. Add a Loop operator to the designer.
  2. Hover over the Loop operator in the Steps Library to expose the Collect operator.
  3. Add the Collect operator within the Loop.
  4. In the Input field, specify the path to the data to collect for each iteration.
    For example, use $.ask_a_question.slack_response to collect all user responses.

    Access and use the Collect operator within a loop.

  5. (Optional) Use as many Collect operators as needed in the same loop to create different sets (arrays) of loop results. In the below example, a second Collect operator is used to gather only the email addresses of the users who declined the request. The path to the user email is $.loop_value.
    How to use multiple collect operators in a single loop.

Was this article helpful?

What's Next
Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.