Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to get display value of variable in Script Include?

Jared Wason
Tera Guru

Hi,

I have a catalog client script that is calling a script include. However the variable is coming back as a sys_id, and I want it to come back as a display value. I have tried using .getDisplayValue() on the sys_id but it just shows up blank on the form. I am referring to line 22 on the catalog client script and 13 on the script include. Anyone see what I am doing wrong?

find_real_file.png

find_real_file.png

 

1 ACCEPTED SOLUTION

Jaspal Singh
Mega Patron
Mega Patron

Hi Jared,

 

For Script include's line 13 can you replace

snResponse.push(snRecord.u_itd_cost_center.toString());

with below

snResponse.push(snRecord.u_itd_cost_center.getDisplayValue().toString()); 

use getDisplayValue() in server side rather than client side.

View solution in original post

2 REPLIES 2

Jaspal Singh
Mega Patron
Mega Patron

Hi Jared,

 

For Script include's line 13 can you replace

snResponse.push(snRecord.u_itd_cost_center.toString());

with below

snResponse.push(snRecord.u_itd_cost_center.getDisplayValue().toString()); 

use getDisplayValue() in server side rather than client side.

Allen Andreas
Tera Patron

Hi,

In your script include, you should be able to dot-walk to the name, if that's available, like:

snRecord.u_itd_cost_center.name

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!