- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2020 04:44 AM
Hi all,
My requirement is :on change of caller ,Caller's manager name should get populate in short description.for this i have written client script On Change of caller with below code:
var man = g_form.getReference('caller_id', setmanager);
function setmanager(man) {
if (man)
alert('manager is '+ man.manager);
g_form.setValue('short_description', man.manager);}
and this is returning sys_id and if i have written below code then its returning no value :
var man = g_form.getReference('caller_id', setmanager);
function setmanager(man) {
if (man)
alert('manager is '+ man.Manager.name);
g_form.setValue('short_description', man.Manager.name);}
Please guide, Thanks in advance.
Thanks,
Priya
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2020 08:21 AM
Hello Priya,
Dot walking will not work in client script. In order to get manager's name you need to call a script include from client script as below.
1. Create a Client script as below:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
var callerID = g_form.getValue('caller_id');
var si =new GlideAjax('getCallerID');
si.addParam('sysparm_name','getUserInfo');
si.addParam('sysparm_caller_id',callerID);
si.getXML(getManager);
function getManager(response){
var manager = response.responseXML.documentElement.getAttribute('answer');
alert("Manager Name: "+manager);
}
}
2. Script Include Code:
Create a script include as below:
Name: getCallerID
Client callable: TRUE (Checked)
var getCallerID = Class.create();
getCallerID.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserInfo: function() {
var userID = this.getParameter('sysparm_caller_id');
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',userID);
gr.query();
if(gr.next()){
var manager = gr.getDisplayValue('manager');
return manager;
}
},
type: 'getCallerID'
});
Please mark as Correct Answer and Helpful, if applicable.
Thank You!
Abhishek Gardade
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2020 07:37 AM
getReference and client side glide records can only get fields directly on the referenced record, the display value is on the managers user record so you can't get it with either of those methods.
To get the display value of the manager you'll need to use Glide Ajax to make a call to the server and return the value to the client, it's best practice anyway as it's more efficient and it's important to know how to configure it. There's a good guide here

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2020 08:01 AM
Hi there,
Try using GlideAjax (with getXMLAnswer). A bit more code, though far more efficient looking at queries and user experiance.
(and please remove some of your double posts about this same question)
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2020 08:21 AM
Hello Priya,
Dot walking will not work in client script. In order to get manager's name you need to call a script include from client script as below.
1. Create a Client script as below:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
var callerID = g_form.getValue('caller_id');
var si =new GlideAjax('getCallerID');
si.addParam('sysparm_name','getUserInfo');
si.addParam('sysparm_caller_id',callerID);
si.getXML(getManager);
function getManager(response){
var manager = response.responseXML.documentElement.getAttribute('answer');
alert("Manager Name: "+manager);
}
}
2. Script Include Code:
Create a script include as below:
Name: getCallerID
Client callable: TRUE (Checked)
var getCallerID = Class.create();
getCallerID.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserInfo: function() {
var userID = this.getParameter('sysparm_caller_id');
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',userID);
gr.query();
if(gr.next()){
var manager = gr.getDisplayValue('manager');
return manager;
}
},
type: 'getCallerID'
});
Please mark as Correct Answer and Helpful, if applicable.
Thank You!
Abhishek Gardade
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2020 01:47 PM
Thanks Abhishek... 🙂