getReference displays sys_id for reference field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2015 08:58 AM
Hi,
I'm trying to populate a set of variables based on the imput of another variable and can't quite find the answer i'm looking for.
for these 2 lines, i get the sys_id but would like the display value. (both fields are reference fields on the user record)
g_form.setValue('location', user.location);
g_form.setValue('cost_code',user.cost_center);
here is my variable script.
----
function onChange(control, oldValue, newValue, isLoading) {
if(!isLoading){
if (oldValue != newValue) {
var User = g_form.getReference('name', fillcustomer);
}
}
}
function fillcustomer(user) {
g_form.setValue('phone',user.phone);
g_form.setValue('location', user.location);
g_form.setValue('desk', user.u_desk);
g_form.setValue('email',user.email);
g_form.setValue('cost_code',user.cost_center);
}
-----
I have trid the following but no joy.
//g_form.setValue('cost_code',user.cost_center.name);
//g_form.setValue('cost_code',user.cost_center.getDisplayValue());
//g_form.setValue('cost_code',user.code);
any help would be greatly appreciated

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2015 09:02 AM
Hi Alan,
You mean when the value is set for the fields it displays sys_id. Any reason you want to have display value to be returned.
If you only want the display value to be returned, then the best way to do so is client script + GlideAjax.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2015 09:08 AM
Hi Pradeep,
correct. this is for a catalogue Item, so the end user will see the values and the sys id means nothing to them.
ok, Client script and GlideAjax?
not sure i've done a glide ajax before, I will give it a try .
any advice?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2015 09:10 AM
Thanks for the update. But in this case when the value is set on the field it will be display value only. Are you not seeing the display value on the reference field created on your table.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2015 09:15 AM