Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How to pass values from a For Each loop into an array flow variable (step by step)?

saint
Tera Expert

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

  1. Use Look Up Records (or similar) to return multiple records
  2. Loop through those records using For Each
  3. Collect each record’s sys_id
  4. Store all sys_ids into one array flow variable
  5. Use that array later in the flow (outside the For Each)

 

Could someone please provide a clear, step‑by‑step example
3 REPLIES 3

lauri457
Tera Sage

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.

123456.png

1234567.png

AnirudhKumar
Mega Sage

I'm an expert flow user, and I can confirm that @lauri457 's solution is the best one. 🙂

pururavasin
Tera Contributor

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