The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Flow designer: how can I separate look up records into a list?

astanley
Tera Contributor

Hello, 

I am currently using a for each loop in flow designer to look up records and set a flow variable with the found records

astanley_0-1668637731262.png

The issue I'm facing is when I use this flow variable down the line, it populates the records without separating them:

astanley_1-1668637840092.png

Where I have covered is the start of a new record. Is there any way I can separate the records into a list or at least be separated by a comma? Thanks!

13 REPLIES 13

Hi,

You can do it.
9-For Each.field1, 9-For Each.field2, 9-For Each.field3 etc.


Thanks and Regards,

Saurabh Gupta

Hi,

They are not fields they are records, so it could be one, two, five, or however many depending on the user. The for each is looking up the records and then I set the flow variable for each record that is found.

Hi,
If I understood correctly, you want a single variable coming out from loop containing the data of each iteration of loop.

Please use like below-
Inside the script section of flow variable


var ret=fd_data.flow_var.ci_string;//assuming ci_string is the name of your flow var
var ci_data=fd_data._9_for_each.item.value;//change as per your syntax
if(ret)
return ret+", "+ci_data;
else
return ci_data;


Please mark the answer as correct, If I answered your query.

Will be helpful for other visitors looking for similar questions.


Regards
Saurabh


Thanks and Regards,

Saurabh Gupta

Yes, I am trying to get each iteration to be in a separate line or separated by a comma. I have tried the above script but it did not work. It gave me an error that it could not retrieve a snapshot for test. I checked if the RITM had been generated (which is the end goal of my flow) and it was not generated.

Did I do something wrong in the script?

var ret=fd_data.flow_var.ci_string;
var ci_data=fd_data._9_for_each.hardware_record.display_name;
if(ret)
return ret+", "+ci_data;
else
return ci_data;

 

Please share the object that you are passing within ForEach.


Thanks and Regards,

Saurabh Gupta