How to get display value of any reference field using Client script?

rathikaramamurt
Giga Expert

Hey,

Could anyone please advise on how to get the display value for any reference field (CI field) using the onSubmit Catalog Client script?

Using g_form.getValue('u_device_ref_1'), I am getting the sys_id of this field

And with g_form.getDisplayValue('u_device_ref_1'), I am getting blank value.

Thanks in Advance,

Rathika.

1 ACCEPTED SOLUTION

PrashantLearnIT
Giga Sage

HI Rathika,



You can use g_form.getDisplayBox('field_name');



Thanks


Prashant


********************************************************************************************************
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.

********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect


Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************

View solution in original post

25 REPLIES 25

Mihir Mohanta
Kilo Sage

You need to use getDisplayBox() function.


Please go through below threads.



Re: getValue on a reference field



Re: catalog client script onsubmit




Thanks,


Mihir


PrashantLearnIT
Giga Sage

HI Rathika,



You can use g_form.getDisplayBox('field_name');



Thanks


Prashant


********************************************************************************************************
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.

********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect


Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************

Does this still work?   I am trying to do this in an OnChange Catalog Client Script for a particular catalog item and "getDisplayBox" is not an option for g_form:



find_real_file.png



I am trying to get the DisplayValue() of a reference field.



Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

I need to post a correction to the above.   This is missing a .value at the end of the statement.   It should be:


g_form.getDisplayBox('field_name').value;



Now this works for me too.



Thanks,


Brad