- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2018 08:33 PM
I want to populate the manager details in the incident form when i choose the caller it should be auto populate in the manager filed.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2018 08:40 PM
Hi Alok,
Refer the OOTB script which populates Location field based on Caller and then create the similar script to populate Manager field.
https://YOURINSTANCENAME.service-now.com/sys_script_client_list.do?sysparm_query=sys_class_name%3Dsys_script_client%5EtableSTARTSWITHincident%5EnameLIKElocation%5Ename%3D(BP)%20Set%20Location%20to%20User
-Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2018 08:40 PM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2018 08:40 PM
Hi Alok,
Refer the OOTB script which populates Location field based on Caller and then create the similar script to populate Manager field.
https://YOURINSTANCENAME.service-now.com/sys_script_client_list.do?sysparm_query=sys_class_name%3Dsys_script_client%5EtableSTARTSWITHincident%5EnameLIKElocation%5Ename%3D(BP)%20Set%20Location%20to%20User
-Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2018 09:58 PM
Hi Alok
You can write on change client script to get the value of manager using script include(make sure client callable checkbox true) or you can directly use dot walking using form layout.
Script include
-----------------
var GetManager = Class.create();
GetManager.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getManager: function() {
var userRecord = new GlideRecord("sys_user");
userRecord.get(this.getParameter('sysparm_userID'));
return userRecord.manager.name + '';
},
type: 'GetManager'
});
Client script
----------------------------
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var getManager = new GlideAjax('GetManager');
getManager.addParam('sysparm_name','getManager');
getManager.addParam('sysparm_userID', g_form.getValue('caller_id'));
getManager.getXML(populateManagerField);
function populateManagerField(response){
var managerFromScriptInclude = response.responseXML.documentElement.getAttribute("answer");
g_form.clearValue('u_manager');
g_form.setValue('u_manager',managerFromScriptInclude);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2018 10:07 PM
Here You go:
function onChange(control, oldValue, newValue, isLoading) {
if ((isLoading && !g_form.isNewRecord()) || (g_form.isLiveUpdating && g_form.isLiveUpdating()))
return;
if (newValue == '' || newValue == null) {
g_form.setValue('u_manager', ''); //Your manager field name
return;
}
if (!g_form.hasField('u_manager'))
return;
var caller = g_form.getReference('caller_id', setManager);
}
function setManager(caller) {
if (caller)
g_form.setValue('u_manager', caller.manager);
}