How to populate List Collector field based on Select box field in Catalog Item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi All,
In one catalog item, I have two fields:
Role Category → this is a Select box field
Sub Category → this should be a list collector where user can select multiple roles. User wants this to be list collector as they want to select multiple roles
We have more than 200 sub values, so hardcoding in client script is not possible.
My requirement is:
When user selects a Main Category, only related Sub Category values should show in the list collector.
Main is single select, Sub is multi select.
What is the simple and best way to do this?
Can we achieve this using a Reference Qualifier and a mapping table?
Or is there a simpler way without too much client-side scripting?
Any suggestions or examples would be very helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Mahalakshmi Rav,
Yes, you can achieve this cleanly without hardcoding using a mapping table + reference qualifier:
1. Create a mapping table u_role_category_map
u_category → Reference to Role Category
u_role → Reference to sys_user_role
2. Script Include (client callable):
var RoleMapAjax = Class.create();
RoleMapAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
isPublic: function() { return true; },
getRolesForCategory: function() {
var cat = this.getParameter('sysparm_category');
var ids = [];
var gr = new GlideRecord('u_role_category_map');
gr.addQuery('u_category', cat);
gr.query();
while (gr.next()) ids.push(gr.u_role.toString());
return ids.join(',');
},
type: 'RoleMapAjax'
});
3. Catalog Client Script:
function getSubRoles() {
var cat = g_form.getValue('role_category');
if (!cat) return '';
var ga = new GlideAjax('RoleMapAjax');
ga.addParam('sysparm_name','getRolesForCategory');
ga.addParam('sysparm_category',cat);
ga.getXMLWait();
var answer = ga.getAnswer();
return answer ? 'sys_idIN' + answer : '';
}
4. Configure List Collector variable
Reference = sys_user_role
Reference qualifier = javascript:getSubRoles()
Result: When user selects a Role Category, the Sub Category list collector will only show the mapped roles.
Thanks & regards,
Siddhesh Jadhav
ServiceNow Community Rising ⭐ Star 2025
Please mark this answer helpful and accepted if it resolved your query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I would not suggest creating a table for this use case, instead use Decision table feature.
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thank you for your suggestion @Siddhesh Jadhav , I'm already making using of an existing u_choice table from my instance.
I tried creating a Script Include and calling it in the onChange Client Script using GlideAjax. It seems that addoption does not work with List Collector. Are there any other ways to implement this? The main functionality should allow sub category (jde_roles & jde_roles_to_be_removed) as List Collector fields.
On change client script:
Script Include:
My catalog variables:
But this script is working when i make the field type as lookup selectbox.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
What is the dependency of subcategory and role category?
Do you have that dependencies in a excel file or do you have some relation between them?
You can consider Decision Tables concept here to return the categories as output if role is matched.
Call the decision table from the script include and use reference qualifier to send the role category to that SI.
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP