- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2019 07:03 AM
Hi,
below code works perfect and returns manager sysid if run for users with ITIL license. However, it's returning undefined for normal end users. Any ideas? Thanks.
I'm trying to run this on client script if user selects a requestor, his manager name should write to console for now.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var usr = g_form.getReference('requestor',callBack);
function callBack(usr){
console.log ("hello2:" + usr.manager);
g_form.setValue('requestor_manager',usr.manager);
}
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2019 06:48 AM
@Allen : It worked on the portal for end users who have ITIL license and not for other users. They will always access this form through portal to request a service.
Hi,
I tried all the suggested combinations and it still didnt work. To make this work, I'm utilizing one of our existing script includes and called it using glideAjax. Surprisingly, this worked without tweaking any ACLs for the user record.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// var usr = g_form.getReference('requestor',callBack);
var ga = new GlideAjax('getUserManager');
ga.addParam("sysparm_name", "getonBehalfOfManager");
ga.addParam("sysparm_user", g_form.getValue('requestor'));
ga.getXML(getResponse);
function getResponse(response) {
var values = response.responseXML.documentElement.getAttribute('answer').toString().split('||');
g_form.setValue('requestor_manager', values[1]);
}
}
/*function callBack(usr){
console.log ("hello: " + usr.manager);
g_form.setValue('requestor_manager',usr.manager.toString());
} */
Here is my code on the script include:
var getUserManager = Class.create();
getUserManager.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getonBehalfOfManager : function(){
var group = this.getParameter('sysparm_user');
var rel = new GlideRecord("sys_user");
rel.addQuery("sys_id", group);
rel.query();
var name_arr = [];
var sys_id_arr = [];
if(rel.next())
{
name_arr.push(rel.manager.name.toString());
sys_id_arr.push(rel.manager.toString());
}
return name_arr.toString() + '||' + sys_id_arr.toString();
},
type: 'getUserManager'
});
Regards,
Krishna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2019 10:07 AM
In that case, you would have to edit the read ACL's on sys_user table for your end users to see data
Please mark my response as correct and helpful if it helped solved your question.
-Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2019 10:37 PM
Hi Krishna,
Any update on this?
Can you mark my answer as Correct, Helpful if you were able to achieve the requirement & then close the thread.
Thanks in advance.
Sanket

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2019 06:29 AM
We're unsure where the no role users are accessing this...do you mean they use the portal and it's not working there, but is working for the back-end users? If so, as Sanket mentions below, please set the UI type to "All" instead of "Desktop" within this client script settings.
Also, please mark my reply above as Helpful (and this one), if it was, as explaining things helps everyone.
Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-17-2019 10:42 AM
Hi,
Not sure but please try doing this usr.manager.toString()
and also check ACLs on user table and specially on manager field if there is any specific field ACL.
Thanks,
Ashutosh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2019 11:00 PM
Hi Krishna,
In your client Script please make sure the filed "UI Type" is marked as "ALL".
Regards,
Sanket