- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2023 11:34 PM
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var mng = g_form.getReference('u_name', ManagerDetails);
function ManagerDetails(mng) {
g_form.setValue('u_manager', mng.manager);
g_form.setValue('u_phone_number', mng.mobile_phone);
}
}
Manager field is showing sys_id, I want the display value. I tried .getValue and .getDisplayValue didn't work.
Also how to modify the above client script with callback function
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2023 11:48 AM
Hi @pk16514
can you please try below script.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var mng = g_form.getReference('u_name', ManagerDetails);
function ManagerDetails(mng) {
var manager = mng.manager;
var phoneNumber = mng.mobile_phone;
// Retrieving display values for the manager reference field
var managerGR = new GlideRecord('user_table'); // Replace 'user_table' with the actual table name
if (managerGR.get(manager)) {
g_form.setValue('u_manager', managerGR.getDisplayValue()); // Sets the display value of the manager field
g_form.setValue('u_phone_number', phoneNumber); // Sets the phone number value
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2023 12:02 AM
Hi @pk16514 ,
Plz find the updated code.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var mng = g_form.getReference('u_name', ManagerDetails);
function ManagerDetails(mng) {
g_form.setValue('u_manager', mng.manager.getDisplayValue());
g_form.setValue('u_phone_number', mng.mobile_phone);
}
}
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2023 11:27 AM
Thanks Danish for your answer but now it doesn't show either the caller manager and caller phone number.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2023 11:48 AM
Hi @pk16514
can you please try below script.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var mng = g_form.getReference('u_name', ManagerDetails);
function ManagerDetails(mng) {
var manager = mng.manager;
var phoneNumber = mng.mobile_phone;
// Retrieving display values for the manager reference field
var managerGR = new GlideRecord('user_table'); // Replace 'user_table' with the actual table name
if (managerGR.get(manager)) {
g_form.setValue('u_manager', managerGR.getDisplayValue()); // Sets the display value of the manager field
g_form.setValue('u_phone_number', phoneNumber); // Sets the phone number value
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2023 11:49 AM
dot walk mayn't work. You may try using a display business rule to and get the user information and then pass the data in scratchpad to client script.
In this thread, there is a good example
Please mark this response as correct or helpful if it assisted you with your question.