- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2020 09:41 AM
Hi Team.
I have a variable set for catalog items that auto-populate with basic user information based on who is logged into SN. It pulls data from the user table. The user should be able to change the user's name in the "Who is this request for?" field if submitting the request on behalf of another person. The rest of the fields should update automatically with the new user's information.
I am able to successfully do this when impersonating an ITIL user, but not when I impersonate a regular non-ITIL user. With the non-ITIL user, I am able to change the "Who is this request for?" field, but the other fields do not update. The organization's field is blank and the Phone number and Email address fields get populated with "Undefined". I have attached screenshots.
I looked through the Service Catalog properties, Catalog UI Policies and ACLs, but I did not find one that could be impacting the variable auto-population for non-ITIL users.
Any information/suggestion that you can provide me will be greatly appreciated.
Thank you.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2020 10:11 AM
EDIT: Made some changes to the code below in the script include for company. Instead of a reference variable make company a string. Then you will not have to worry about ACLs.
Here is a script include along with the updated client script. Note this still doesn't now work for company as it appears the core_company table has a read ACL on it with a bunch or roles. Not sure why. You may want to contact your ServiceNow account rep to see if it is a licensing issue to remove the roles from that ACL.
Script Include: Make sure the name of the script include is GetUserData and that you check client callable.
var GetUserData = Class.create();
GetUserData.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getCompany: function () {
gs.log('in company funcation');
var gr = new GlideRecord('sys_user');
var sys_id = this.getParameter('user_sys_id');
gr.addQuery('sys_id', sys_id);
gr.query();
if (gr.next()){
return gr.getDisplayValue('company');
}
},
getPhone: function () {
var gr = new GlideRecord('sys_user');
var sys_id = this.getParameter('user_sys_id');
gr.addQuery('sys_id', sys_id);
gr.query();
if (gr.next()){
return gr.phone;
}
},
getEmail: function (){
var gr = new GlideRecord('sys_user');
var sys_id = this.getParameter('user_sys_id');
gr.addQuery('sys_id', sys_id);
gr.query();
if (gr.next()){
return gr.email;
}
},
type: 'GetUserData'
});
Updated Client script:
function onChange(control, oldValue, newValue, isLoading) {
if (newValue == '') {
return;
}
var user = g_form.getValue('requested_for');
var userCompany = new GlideAjax('GetUserData');
userCompany.addParam('sysparm_name', 'getCompany');
userCompany.addParam('user_sys_id', user);
userCompany.getXML(Company);
var userPhone = new GlideAjax('GetUserData');
userPhone.addParam('sysparm_name', 'getPhone');
userPhone.addParam('user_sys_id', user);
userPhone.getXML(Phone);
var userEmail = new GlideAjax('GetUserData');
userEmail.addParam('sysparm_name', 'getEmail');
userEmail.addParam('user_sys_id', user);
userEmail.getXML(Email);
}
function Company(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('company', answer);
}
function Phone(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('phone', answer);
}
function Email(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('email', answer);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2020 12:56 PM
Thanks again. It worked for the ITIL user. But the non-ITIL user is still not able to update the fields with another user's information. They can update the user's name, but the company field is blank and the email and phone fields are auto-populated with Undefined.
Willem indicated above that there is an ACL for the sys_user table that could be impacting this process. I provided a screenshot of the ACL.
If this is the next step for me to take, any suggestion on how to modify the ACL?
Greatly appreciate your help!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-04-2020 04:47 PM
Strange this used to work for me. I think we will need to build out a script include and call it thought glide ajax.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2020 10:11 AM
EDIT: Made some changes to the code below in the script include for company. Instead of a reference variable make company a string. Then you will not have to worry about ACLs.
Here is a script include along with the updated client script. Note this still doesn't now work for company as it appears the core_company table has a read ACL on it with a bunch or roles. Not sure why. You may want to contact your ServiceNow account rep to see if it is a licensing issue to remove the roles from that ACL.
Script Include: Make sure the name of the script include is GetUserData and that you check client callable.
var GetUserData = Class.create();
GetUserData.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getCompany: function () {
gs.log('in company funcation');
var gr = new GlideRecord('sys_user');
var sys_id = this.getParameter('user_sys_id');
gr.addQuery('sys_id', sys_id);
gr.query();
if (gr.next()){
return gr.getDisplayValue('company');
}
},
getPhone: function () {
var gr = new GlideRecord('sys_user');
var sys_id = this.getParameter('user_sys_id');
gr.addQuery('sys_id', sys_id);
gr.query();
if (gr.next()){
return gr.phone;
}
},
getEmail: function (){
var gr = new GlideRecord('sys_user');
var sys_id = this.getParameter('user_sys_id');
gr.addQuery('sys_id', sys_id);
gr.query();
if (gr.next()){
return gr.email;
}
},
type: 'GetUserData'
});
Updated Client script:
function onChange(control, oldValue, newValue, isLoading) {
if (newValue == '') {
return;
}
var user = g_form.getValue('requested_for');
var userCompany = new GlideAjax('GetUserData');
userCompany.addParam('sysparm_name', 'getCompany');
userCompany.addParam('user_sys_id', user);
userCompany.getXML(Company);
var userPhone = new GlideAjax('GetUserData');
userPhone.addParam('sysparm_name', 'getPhone');
userPhone.addParam('user_sys_id', user);
userPhone.getXML(Phone);
var userEmail = new GlideAjax('GetUserData');
userEmail.addParam('sysparm_name', 'getEmail');
userEmail.addParam('user_sys_id', user);
userEmail.getXML(Email);
}
function Company(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('company', answer);
}
function Phone(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('phone', answer);
}
function Email(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('email', answer);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2020 06:05 AM
Thanks a lot, Brian. The new information worked. Greatly appreciate your help!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2020 10:04 AM
Hi Joy,
It seems the ACL on user table doesn't allow to read information for users doesn't have ITIL role.
I have a work around for this, I assume you are using glideajax to fetch information via script include.
var dummyItiluser = "<sys_id_of_dummy_user_with_itil_role>";
var myUser = gs.getSession().impersonate(dummyItiluser);
//write your script include method code inside this
gs.getSession().impersonate(myUser);