How to retrieve string name of selected list items in flow designer

Brian Hofmeiste
Kilo Guru

Hello!  

 

My form has a list of departments and users are able to select multiples.  In flow designer I want to grab the names of all departments they selected.  Is this possible with just flow designer or do i need a script?  If a script, can you suggest something?  thanks so much.

 

Brian

1 ACCEPTED SOLUTION

Brian Hofmeiste
Kilo Guru

Thanks to everyone who provided feedback on this.  Each of your answers helped me determine my best approach.  I ended up doing the following:

 

1. Retrieve the list of departments they selected on form.  This comes in the form of a comma separated string.

2. I created a custom action to turn that comma separated string in to an array.

3. I used a FOR EACH loop in the flow designer to cycle through the array.  I wrote each department name in to a string called departments.

4. i added that departments string to the story record where I wanted it to land.

View solution in original post

7 REPLIES 7

We don't have to parse string to array, The condition "is one of" can work with the comma separated values.

In your lookup records you can use 'sys_id || is one of || your list data pill'.

 

Alternate way to get all the department names, 

1. Create a flow variable.

2. Use Set Flow Variable with script option to get all the department names.

VoonaRohila_0-1726208810861.png

 

//Use below code in set flow variable script part.
var grCD = new GlideRecord('cmn_department');
grCD.addEncodedQuery("sys_idIN"+fd_data.trigger.request_item.watch_list); // change the fd_data as per your requirement.
grCD.query();
var dep = [];
while (grCD.next()) {
   dep.push(grCD.name.toString())
}
return dep.toString();

 

 

3. Use Above flow variable in your action( You can just drag and drop the flow variable pill)]

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
4x ServiceNow MVP

Brian Hofmeiste
Kilo Guru

Thanks to everyone who provided feedback on this.  Each of your answers helped me determine my best approach.  I ended up doing the following:

 

1. Retrieve the list of departments they selected on form.  This comes in the form of a comma separated string.

2. I created a custom action to turn that comma separated string in to an array.

3. I used a FOR EACH loop in the flow designer to cycle through the array.  I wrote each department name in to a string called departments.

4. i added that departments string to the story record where I wanted it to land.