Dynamic Location Filtering in Catalog Item based on Requestor, Role, and Stockroom (cmn_location)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Hi All,
I am working on a ServiceNow catalog requirement where I need to dynamically filter a Location reference field based on multiple conditions like user role, requestor, hierarchy, and stockroom availability.
Scenario:
I have a Catalog Item with two Variable Sets:
Variable Set 1
Field:
Requestor For(Reference → sys_user)
Variable Set 2
Field:
Location(Reference → cmn_location)
🔹 Location Table Structure (cmn_location):
The hierarchy is as follows:
Region (e.g., APAC) → top level (parent is empty)
Country (e.g., India) → child of Region
🔹 Conditions:
I need to filter the Location field based on:
Location attributes:
cmn_location_source = xxxxxcmn_location_type = xxxx
Stockroom condition:
Only locations that have a related record in alm_stockroom (i.e., location has a stockroom)
User role:
If user has itil role → show Region level (APAC)
If user is end user → show Country level (India)
Requestor-based filtering:
Based on selected Requestor For, restrict locations within the same hierarchy
🔹 What I Have Tried:
Created a Script Include (GlideAjax) to build dynamic query
Used Catalog Client Script (onChange) on
Requestor ForApplied
g_form.setReferenceQualifier()on Location field
🔹 Issue:
Since Requestor For and Location are in different variable sets,
I am unsure about the best approach to:
Trigger filtering correctly
Apply dynamic reference qualifier
Ensure it works across multiple catalog items
🔹 Questions:
What is the best practice to handle filtering when variables are in different variable sets?
Is GlideAjax + onChange the right approach, or can this be achieved using a reference qualifier?
What is the optimal way to filter locations based on:
hierarchy (parent / parent.parent)
stockroom availability (alm_stockroom)
How to make this reusable across multiple catalog items?
🔹 Any suggestions or best practices would be greatly appreciated.
Thanks in advance!