onChange client script is returning sys_id, but I want the field's value instead
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2020 12:28 PM
Hi everyone,
We have a record producer with a field for employee name. Once the user enters the employee name, we want a separate field to be auto-filled in with that employee's department name. Here is the onchange client script I have written:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
g_form.setValue('ouc', '');
return;
}
var caller = g_form.getReference('customer', getOUC);
}
function getOUC(caller) {
g_form.setValue('ouc', caller.department);
}
Unfortunately, this script returns the sys_id but not the variable value. I've tried updating the final line as follows, but it didn't help:
g_form.setValue('ouc', caller.department.getDisplayValue());
Any ideas what I am doing wrong? Thanks in advance for any help you can offer!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-11-2020 12:36 PM
Is 'OUC' not a reference field? If not you can try using caller.department.name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2020 06:37 AM
Hi Jaspal,
OUC is the label name but the actual field name in the cmn_department table that I want is the 'id' field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-12-2020 09:00 AM
you can solve this requirement either you change your "ouc" field as reference variable and then populate the sys_id in ouc variable.
or other way would be , create glide ajax. to get the display name of the value. because call back-function will only work at one level of dot walk.
glide ajax is not so hard , if you are new i would suggest go through the doc link and then write the script .