How to push data into array variable in flow designer after for each loop?

PetrP
Tera Expert

How to push data into array variable in flow designer after for each loop? 

I know to script this in action, but it should not be part of action. How to do it as below in flow directly?

PetrP_0-1717062383846.png

 

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@PetrP 

did you try to explore on flow variable which you can try to append?

it doesn't support array as type so I believe the only way is to use custom action with script

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Danmax
Tera Expert

Hi I recently tried doing the same pushing values from a repeater to a Flow Variable to build a list of sysIds

I did something like this and it worked beautifully check it out 

const list = fd_data.flow_var.ranklist? fd_data.flow_var.ranklist:[];
list.push(fd_data.flow_var.competitor);
return list

instead of initiating the variable with an empty array in another action we check with a "?" if there is a value then if True use the value else set it as an empty array with "[ ]" then we can push the new value to the array and return the list. 

push to array.PNG

scottl
Kilo Sage

This is basic programming 101 and Flow designer can't even do this, AND we're being forced as developers to use Flow designer?  And why has this not been answered by any of the ServiceNow employees on this board? 

And WHY can we still today not able to create an ARRAY when declaring a flow variable?