Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

On incident form whenever I change the caller, His manager autopopulate in the string feild

VaishakP1978942
Tera Contributor

On incident form whenever I change the caller, His manager autopopulate in the string feild

1 ACCEPTED SOLUTION

Ankur Kasana
Tera Expert

Hi Vaishak 

 

You need to write onChange client script for this requirement. Use below script 

 

Client Script : Write in Caller field

 

var aj = new GlideAjax('script include name');

aj.addParam('sysparm_name', 'getManager');

aj.addParm('sysparm_val', newValue);

aj.getXMLAnswer(executeForManager);

 

function executeForManager(answer){

g_form.setValue('Field Name', answer);

}

 

Script Include Function : 

 

getManager : function(){

var callerID = this.getParameter('sysparm_val');

 

var userGr = new GlideRecord('sys_user');

if(userGr.get(callerID)){

return userGr.manager.getDisplayValue();

}

}

 

Note : Replace the red highlighted text with your record name.

 

Please mark my answer helpful after implementing it.

View solution in original post

2 REPLIES 2

Nikhil Bajaj9
Tera Sage
Tera Sage

If it is a requirement and you want to achieve it then you can do it using Glide Ajax.

Please appreciate my efforts, help and support extended to you by clicking on – “Accept as Solution”; button under my answer. It will motivate me to help others as well.
Regards,
Nikhil Bajaj

ServiceNow Rising Star-2025

Ankur Kasana
Tera Expert

Hi Vaishak 

 

You need to write onChange client script for this requirement. Use below script 

 

Client Script : Write in Caller field

 

var aj = new GlideAjax('script include name');

aj.addParam('sysparm_name', 'getManager');

aj.addParm('sysparm_val', newValue);

aj.getXMLAnswer(executeForManager);

 

function executeForManager(answer){

g_form.setValue('Field Name', answer);

}

 

Script Include Function : 

 

getManager : function(){

var callerID = this.getParameter('sysparm_val');

 

var userGr = new GlideRecord('sys_user');

if(userGr.get(callerID)){

return userGr.manager.getDisplayValue();

}

}

 

Note : Replace the red highlighted text with your record name.

 

Please mark my answer helpful after implementing it.