How to convert sysid to display value in the catalog form

Naresh291
Tera Contributor

Hi ,

I have a client script on the catalog form . There is a field called 'division' in the form which should autopopulate the value of 'division' field also present in the user table  according to the  requested for. I have a script include where i have fetched the values from user table and i have called the script include from client script . The problem is now i get a sysid instead of display value . Even if i use toString() or getDisplayValue still it gives me the sysid instead of displayvalue .

Here is the line of code in script include:

result.setAttribute('division', gr.u_division);

where gr is the glideRecord of sys_user table and the division field in the user table is a reference field refering to division table .

Client script:

.

.

ga.getXML(employeeInfo);

function employeeInfo(serverResponse) {
var result = serverResponse.responseXML.getElementsByTagName("result");
var div = result[0].getAttribute("division");

g_form.setValue("division",div );
}

 

Any leads on this is highly appreciated

 

Regards,

Naresh

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

You can get the display value of reference field in the script include function

result.setAttribute('division', gr.u_division.getDisplayValue());

Regards
Ankur

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

View solution in original post

5 REPLIES 5

Hi,

yes in client script you can get display value of reference field like this

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

Regards
Ankur

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