Unable to get value of referance field in client script

Snehal13
Kilo Sage

I am trying to get value of ref field in client with g_form.getValue("fieldname"); but it returns nothing.

Even g_form.getDisplayBox("fieldname"); gives no value.

All other field values are getting returned in the client script except ref field.

What is alternative.

12 REPLIES 12

Ankur Bawiskar
Tera Patron
Tera Patron

@Snehal13 

you want to get display value of reference field?

if yes and you are doing this in native and for normal form then this should work fine

var value = g_form.getDisplayBox('fieldName').value;

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

I forgot to add- This is a workspace client script. 

var value = g_form.getDisplayBox('fieldName').value; isnt working.

Mohith Devatte
Tera Sage
Tera Sage

hello @Snehal13 ,

Did you try alerting the value ? 

put that in alert and let me know if its returning the value 

I get no value in alert