How to Get the DisplayValue of a Reference on the “Client Side” in ServiceNow

I was working with a client recently and had the need to get the Display Value of a Reference field that was on the form. I didn’t want to have to make an AJAX call just to pull this value (on the server side you would use the “getDisplayValue()” function), and that’s when it hit me. The client already has this value, why not use it? Initially I was thinking about DOM/jQuery which was not going to be ideal. As I dug further I uncovered a little known method to pull the Display Value from a reference field. Drum roll please!

g_form.getDisplayBox('field_name').value

Hopefully this saves someone some time in the future.

2 thoughts on “How to Get the DisplayValue of a Reference on the “Client Side” in ServiceNow

  1. Varun says:

    Hi,

    g_form.getDisplayBox(‘field_name’).value is working in desktop view, but it is not supporting in mobile view.
    Do you have any idea about how can we achieve this functionality in mobile view.

    • jmaxwell says:

      Hi Varun,

      Unfortunately there is not a good method to do this in mobile. In this scenario, the only option I know of is to get it from the server.

Leave a Reply

Your email address will not be published. Required fields are marked *