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.

GlideRecord get label of reference field instead of sys_id

Tadz
Kilo Sage

Hi, is there a way to get the label of the reference field from GlideRecord. instead of sys_id?

Here are some screenshots:

                  Specifications: u_topic field is referenced from another table.

q2.PNG

q1.png

9 REPLIES 9

giriprasad9
Tera Expert

Hi Cris,



Use getDisplayValue()



-Giri


Brian Dailey1
Kilo Sage

Hi Chris,



Since it looks like you're working on a client-side script, you can't use GlideRecord's getDisplayValue() method, which is only server-side.   And you can't dot-walk to drill down through the referenced record to it's display value field.



Since you have to pull a set of records and get both sys_id (for the value) as well as the display value, I would suggest writing an AJAX script to compile and return the data you need:



GlideAjax - ServiceNow Wiki



Your other option might be to manage it through a reference qualifier for your reference drop-down.




Thanks,


-Brian


Robert Beeman
Kilo Sage

Is this a custom table? Do you have the display column set to true for the field you'd like to see?


http://wiki.servicenow.com/?title=Reference_Fields#Selecting_the_Display_Value&gsc.tab=0


What Robert said