- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2022 05:43 AM
Hi,
I have in my form a list collector for the locations table. In my flow, I need to only get the name of each location and then join everything together in a string to pass it to a REST request.
Do you have any idea how to proceed?
Thank you,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2022 12:58 AM
The flow triggers on "Service Catalog". I am using the script on a "Set Flow Variables" step. I managed to do after searching for a long time. Here is my code:
var regionSysID = fd_data._1__get_catalog_variables.regions; // get the comma separated sys_ids
var list = regionSysID.split(","); //store it in an array
var regionArray = [];
for (var i=0; i < list.length; i++) {
var loc = new GlideRecord('cmn_location');
loc.get(list[i]);
regionArray.push(loc.getDisplayValue());
}
return regionArray.toString();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2022 07:16 AM
Hi there,
It should be as easy as this one line of code (I'm not sure what the name of your Locations list field is, so update accordingly):
var locationNameList = current.getDisplayValue('u_locations');
If this answer is helpful please mark correct and helpful!
Regards,
Christopher Perry
Regards,
Chris Perry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2022 12:32 AM
Hi,
Thank you for your help, but it's not working. I get "Cannot convert null to an object" when I test my flow. The variable name in my form is called "regions" and as I said it's a list with references to the cmn_location table.
I tried:
var regionList = current.getDisplayValue("regions");
I also tried to iterate though the list, but that also did not work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2022 12:45 AM
Can you share the flow step where you are using this script?
Flow triggers on?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-20-2022 12:58 AM
The flow triggers on "Service Catalog". I am using the script on a "Set Flow Variables" step. I managed to do after searching for a long time. Here is my code:
var regionSysID = fd_data._1__get_catalog_variables.regions; // get the comma separated sys_ids
var list = regionSysID.split(","); //store it in an array
var regionArray = [];
for (var i=0; i < list.length; i++) {
var loc = new GlideRecord('cmn_location');
loc.get(list[i]);
regionArray.push(loc.getDisplayValue());
}
return regionArray.toString();