Using getReference on Catalog Client Script and I get sysid of location from sys_user table

Mohamed4
Tera Contributor

I am using getReference on Catalog Client Script to get information about the Requester from sys_user and i get sysid of the location field.

is there a way to get the Value instead of the sysid?

any help would be appreciated

 

here is the script below

 

unction onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

var reqByName = g_form.getReference('u_requested_by', callback);

function callback(reqByName) {

var offc = reqByName.u_office.getDisplayValue();
g_form.setValue('u_req_by_office',offc);

g_form.setValue('u_req_by_location1', reqByName.location);
g_form.setValue('u_req_by_location2', reqByName.u_desk_location);
}

}

6 REPLIES 6

Allen Andreas
Administrator
Administrator

Hello,

The location field on the sys_user record is a reference, the value of reference fields is a sys_id. So that is the value. I assume you mean you want the display value or "name" of the location, correct?

Your script is a bit confusing because you used getDisplayValue() for the u_office field, so if that's working for you, then you'd do the same for location (again, if you meant the display value for that field).

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Mohamed4
Tera Contributor

Thanks for replying

Yes i need the location Display Value, the office is also a reference field and it is not displaying the value.

 

Shakeel Shaik
Giga Sage
Giga Sage
var offc = reqByName.u_office.toString();
Thanks,
Shakeel Shaik 🙂

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

var reqByName = g_form.getReference('u_requested_by', callback);

function callback(reqByName) {
 
g_form.setValue('u_req_by_office', reqByName.u_office);

g_form.setValue('u_req_by_location1', reqByName.location);
g_form.setValue('u_req_by_location2', reqByName.u_desk_location);
}

}
Thanks,
Shakeel Shaik 🙂