From a list of reference to string

Tristanct
Tera Expert

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,

1 ACCEPTED SOLUTION

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();

View solution in original post

7 REPLIES 7

@Tristanct 

much simpler line and no need to query

return fd_data.trigger.request_item.variables.regions.getDisplayValue();

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

Regards
Ankur

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

I just tried and it does not return anything. Would getDisplayValue() work even though it's a list and not a unique reference?

Hi,

yes I have used it in the past and it worked fine

what it returns?

Regards
Ankur

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