Updating user details on change on catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I have some fields that I use in a variable set that is meant to show some user details when a users name is selected:
eg - Add a users name "Joe Dirt" and 3 other fields update automatically to show the users logon ID, email address and department for example. Change the name that is in there already and the new users details update in the 3 other fields.
Now I am well aware of the "auto-populate" option in a variable and have tried it. It works for me, but here is the catch, it is not working for a standard user, only for those with a role such as ITIL or Business Stakeholder
So when Jane wants to log a request for Joe to get access to something and the resolver team requires that Joe's email, logon ID and Department are filled in, it will not populate for her.
Anyone know how I can fix this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Other wise by getReference() method also you can fetch data with onchange client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @dannyprime !!
Auto-populate in catalog variable sets only works for users with read access to the referenced fields. Standard users often don’t have access to fields like email, department, or user_name on the sys_user table, which is why the auto-populate fails.
Adjust ACLs to allow read access to standard users for the necessary fields (careful with security).
Use a Catalog Client Script + GlideAjax to fetch and populate fields securely without changing ACLs.
Catalog client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || !newValue) return;
var ga = new GlideAjax('UserDetailsAjax'); // your Script Include
ga.addParam('sysparm_name', 'getUserDetails');
ga.addParam('sysparm_user_sys_id', newValue);
ga.getXMLAnswer(function(response){
var details = JSON.parse(response);
g_form.setValue('email', details.email);
g_form.setValue('logon_id', details.user_name);
g_form.setValue('department', details.department);
});
}Script Include (server side):
var UserDetailsAjax = Class.create();
UserDetailsAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserDetails: function() {
var userSysId = this.getParameter('sysparm_user_sys_id');
var userGR = new GlideRecord('sys_user');
if (userGR.get(userSysId)) {
return JSON.stringify({
email: userGR.email + '',
user_name: userGR.user_name + '',
department: userGR.department.getDisplayValue()
});
}
return '{}';
}
});
Mark this as Helpful if it clarifies the issue.
Accept the solution if this answers your question.
Regards,
Vaishnavi
Technical Consultant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
If the information is for the fulfillers, why does the information need to be surfaced on the form?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @dannyprime
The "Auto-populate" feature in ServiceNow executes client-side, meaning it runs with the permissions of the currently logged-in user. If "Jane" (your standard user) does not have permission to read the email or department fields on the sys_user table for other people, the system returns nothing, and the fields remain blank
Bypass method is
Step 1: Create a Script Include
-
Name: UserMapUtil
-
Client callable: Checked
var UserMapUtil = Class.create();
UserMapUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserDetails: function() {
var userSysId = this.getParameter('sysparm_userID');
var result = {};
var gr = new GlideRecord('sys_user');
if (gr.get(userSysId)) {
// We can read these fields because this runs as System
result.email = gr.getValue('email');
result.user_name = gr.getValue('user_name');
result.department = gr.getDisplayValue('department');
}
return JSON.stringify(result);
},
type: 'UserMapUtil'
});
Step 2: Create a Catalog Client Script
-
Type: onChange
-
Variable: (Your "User Name" variable)
-
UI Type: All
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('UserMapUtil');
ga.addParam('sysparm_name', 'getUserDetails');
ga.addParam('sysparm_userID', newValue);
ga.getXMLAnswer(function(response) {
var userObj = JSON.parse(response);
// Replace these with your actual variable names
g_form.setValue('email_variable', userObj.email);
g_form.setValue('logon_id_variable', userObj.user_name);
g_form.setValue('department_variable', userObj.department);
});
}
Happy to help!
To help others in the community find this solution, kindly mark this response as the Correct Answer and Helpful.
Warm Regards,
Deepak Sharma
Community Rising Star 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
1st of all why you require those 3 extra variables?
You already have reference variable and fulfillers/agents can navigate into that record using the i icon and see the ID, email and department.
You should consider discussing this with your customer and keep the form clean
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
