- 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-03-2020 09:46 AM
The sys_user (User) table has security on it only allowing internal users/user with a role to Access details from the user table.
Users without roles can only see details for their own user record.
You can check this by looking at the Read ACL's (Security Rules) on the sys_user table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2020 06:35 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2020 08:54 AM
Good morning, Willem.
Thanks again for your information.
How would you suggest to modify the above ACL to allow the variables to auto-populate with a different user's information when another user is submitting the request on their behalf?
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2020 08:56 AM
Good morning, Willem.
Thanks again for your information.
How would you suggest to modify the above ACL to allow the variables to auto-populate with a different user's information when another user is submitting the request on their behalf?
Thank you.