Flow Designer - Inline scripting: Get display values from List field

Community Alums
Not applicable

Does anyone know how to get the display values from a List field within an inline script in Flow Designer?

Here is the information:

-  List field is on the core_company field called "u_sub_id"

-  The flow runs against a catalog item that contains a reference variable (called "customer") that references [core_company]

-  Within the inline script, I want to return the first entry in the List field into a variable.  Since the variable references core_company, I can dot-walk to the "u_sub_id" field.  However, when I print out the results of the variable to the log, it is returning "object GlideRecord". 

Here are some of the things I've tried in the inline script:

var test2 = fd_data.trigger.request_item.requested_for.company.u_sub_id.toString();
gs.info("Test2: " + test2);    // returns "[object GlideRecord]"

// _2__update_record is updating the RITM record
var list = fd_data._2__update_record.record.requested_for.company.u_sub_id.toString();
gs.info("subID: " + list);  // returns "[object GlideRecord]"
 
 
Any help would be greatly appreciated.
 
1 ACCEPTED SOLUTION

Hi,

how the values in the list field looks like?

So are you saying it is only returning only the 1st choice

can you share the image how many choices that list field has

As an alternative can you try this

return fd_data._1__get_catalog_variables.customer.u_sub_id.getValue();
 
OR
 
Query the core_company table with this sys_id and get the value
 
var rec = new GlideRecord('core_company');
rec.addQuery('sys_id', fd_data._1__get_catalog_variables.customer);
rec.query();
if(rec.next()){
return rec.u_sub_id;
//OR
return rec.u_sub_id.getValue();
// OR
return rec.u_sub_id.getDisplayValue();

}

Regards
Ankur

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

View solution in original post

10 REPLIES 10

simonluu
Kilo Explorer

Nevermind...I figured it out. Thx.

SNOW doc is not great at explaining. However, you can follow the below steps:

1. Create your input variable first in Flow Action, save, publish.

2. Then go to the Flow Designer + new Action or/refresh, select your Action

3. The variable you created [@ bullet 1] now should show up

4. Here you can assign it (via pill or script)

5. Then your Flow Action will be able to use it.

 

Happy coding!