Collect loop results
- 14 Apr 2024
- 1 Minute to read
- DarkLight
Collect loop results
- Updated on 14 Apr 2024
- 1 Minute to read
- DarkLight
Article Summary
Share feedback
Thanks for sharing your feedback!
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
- Add a Loop operator to the designer.
- Hover over the Loop operator in the Steps Library to expose the Collect operator.
- Add the Collect operator within the Loop.
- 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. - (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.
Was this article helpful?