How to pass values from a For Each loop into an array flow variable (step by step)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi Community,
I’m working in ServiceNow Flow Designer and I’m trying to clearly understand the correct, supported way to collect values from a For Each loop and store them into an array flow variable, so the values are available after the loop finishes.
What I’m trying to do
- Use Look Up Records (or similar) to return multiple records
- Loop through those records using For Each
- Collect each record’s sys_id
- Store all sys_ids into one array flow variable
- Use that array later in the flow (outside the For Each)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
What is it that you are trying to do?
I'd probably do something like this. I'm not a regular flow user so maybe there is a better way.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I'm an expert flow user, and I can confirm that @lauri457 's solution is the best one. 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello,
You can create a "Subflow" which will iterate through all the active Incidents and return the Assignment Groups as a set of Sys-Ids in the form of Subflow output.
Hence, you can use this Subflow in any of the Flow.
Please mark the answer as Helpful or Accept the solution if this content has helped in resolving your query.
Best Regards,
Puru
