Advanced Reference Qualifier on Service Catalog Item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-10-2025 12:25 PM
Hi there,
I'm currently working on a catalog item that includes a reference variable called "Requested_by" (sys_user), and another called "Asset" (alm_hardware). I'm trying to make it so the "Asset" variable only displays hardware assets that have an assigned to value, which is the same as the "Requested_by" variable.
I've tried the following advanced reference qualifier, but I'm having no luck.
javascript:"assigned_to="+current.variables.requested_for
I'm aiming to have the "Asset" variable only display hardware assets that are assigned to the user specified in the "Requested by" variable.
Thanks,
Laurence
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2025 07:35 AM
To display only hardware assets assigned to the user selected in the "Requested_by" variable, you need to use a dynamic reference qualifier with a client-side condition. First, ensure your "Asset" variable is set to use an advanced reference qualifier. In the qualifier script, use: javascript:'assigned_to=' + current.variables.requested_by. This approach assumes that the variable name is correctly referenced as "requested_by". If this doesn't work on its own, you should add a Catalog Client Script of type "onChange" on the "requested_by" variable. In the script, clear the "Asset" field and refresh it using g_form.setValue('asset', ''); g_form.refreshOptions('asset');. This ensures the "Asset" options are updated based on the new user selected. Make sure the "Asset" variable is referencing the alm_hardware table, and that those records have the "assigned_to" field populated. Also, double-check that your variable names in the form match those used in your script. If the issue persists, confirm whether you're using a record producer or a different context, as the script might need adjustmenT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2025 07:41 AM
Fix the Client Script:
In Service Portal, getListCollectorValue doesn't always work as expected. Instead, use g_form.getValue('unit_managers'), and ensure you split the comma-separated values correctly before sending to the Script Include.
Updated onChange Client Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || !newValue) return;
// Get selected users as comma-separated string
var unitManagers = g_form.getValue('unit_managers');
// Clear options if nothing selected
if (!unitManagers) {
g_form.clearOptions('requested_support_group');
return;
}
// Call Script Include
var ga = new GlideAjax('GroupManagerUtils');
ga.addParam('sysparm_name', 'getGroupsByUnitManagers');
ga.addParam('sysparm_managers', unitManagers); // comma-separated
ga.getXMLAnswer(function(response) {
try {
var groups = JSON.parse(response);
g_form.clearOptions('requested_support_group');
if (groups.length > 0) {
groups.forEach(function(group) {
g_form.addOption('requested_support_group', group.sys_id, group.name);
});
} else {
g_form.addOption('requested_support_group', '', '-- No groups found --');
}
} catch (e) {
g_form.addErrorMessage('Error loading groups: ' + e.message);
}
});
}
ix the Script Include:
Your Script Include is fine, but the field is likely not named u_unit_manager (singular). Since you said it’s a List field on the group table, the correct query is u_unit_manager IN sys_id1,sys_id2.
Make sure:
The field name on the sys_user_group table is exactly u_unit_manager (or u_unit_managers if that's plural).
The field is a List type (not reference).
You're checking for multiple sys_ids with IN.
Updated Script Include (keep as is if already correct):
var GroupManagerUtils = Class.create();
GroupManagerUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getGroupsByUnitManagers: function() {
var managerList = this.getParameter('sysparm_managers');
if (!managerList) return '[]';
var groups = [];
var gr = new GlideRecord('sys_user_group');
gr.addQuery('u_unit_manager', 'IN', managerList);
gr.query();
while (gr.next()) {
groups.push({
sys_id: gr.getUniqueValue(),
name: gr.getDisplayValue('name')
});
}
return JSON.stringify(groups);
},
type: 'GroupManagerUtils'
});
Other Tips:
Confirm the field u_unit_manager (or u_unit_managers) is indexed for better performance.
Ensure both fields are visible on the form when testing.
If you’re using multi-row variable sets, this won’t work unless scoped per row.
If this resolves your issue, don’t forget to mark the response as solved on the community. Let me know if it’s still not populating.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2025 11:24 AM
I'm guessing this was meant for another post here on the community!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2025 11:23 AM
Thank you for all of this Jessica! I've checked my work and implemented everything you mentioned, and it's still not working unfortunately. I am guess there is some other bug conflicting with my reference qualifier etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2025 07:52 AM
are you using correct variable name in ref qualifier?
share variable config screenshots.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader