Getting display values from a Glide list in Flow Designer

Peter24
Mega Expert

Hello! I am creating a new flow in Flow Designer for a custom scoped application. One of the requirements is to have the description on a newly created child task contain the values from a field. This field is a Glide list, which means it's a collection of sys_IDs referencing another object. But of course rather than the IDs I want to show the actual display values.

This documentation from ServiceNow contains code on how to parse out the display values. Here is the relevant code they provide:

// list will contain a series of display values separated by a comma
// array will be a javascript array of display values
var list = current.watch_list.getDisplayValue();
var array = list.split(",");
for (var i=0; i < array.length; i++) {
   gs.print("Display value is: " + array[i]);
}

So in my flow, I wrote a similar script for the description on the task:

 /*
**Access Flow/Action data using the fd_data object. Script must return a value.
**example: var shortDesc = fd_data.trigger.current.short_description;
**return shortDesc;
*/

var list = fd_data.trigger.current.choose_portfolio.getDisplayValue();
var array = list.split(",");
gs.info('my array list: ' + array.toString());
var clients = '';
for (var i=0;i < array.length;i++){
    if (i == array.length - 1)
            clients += array[i];
    else
        clients += array[i] + ', ';
}
var desc = 'Mortgagee Clause & Logo Change for Client(s): ' + clients; 
return desc;

However, whenever the flow is run the description only contains the string part: "Mortagagee Clause & Logo Change for Client(s)". The 'clients' variable returns nothing. Does anyone know what I am doing wrong?

Any help is appreciated. Thanks!

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

Hi Peter,

Let me know if that answered your question.

If so, please mark my response as ✅ correct & 👍 helpful so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

Regards
Ankur

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

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron

Hi,

if you are able to get displayValue in line below why are you iterating over using for loop

var list = fd_data.trigger.current.choose_portfolio.getDisplayValue();

Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

Ankur Bawiskar
Tera Patron

Hi Peter,

Let me know if that answered your question.

If so, please mark my response as ✅ correct & 👍 helpful so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

Regards
Ankur

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