- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago - last edited a month ago
Hi all,
I'm trying to conditionally filter a list view of the cmdb_ci_server table depending on how the user navigates to it.
Goal:
If the list is accessed directly via table navigation (e.g., cmdb_ci_server_list.do)
→ I want to apply a filter: manufacturer = VMware, Inc.
If the list is accessed via a reference field (e.g., u_server)
→ I want to show all records without any filter.
Question:
Is there any reliable way to distinguish whether a list view is opened from a reference field
or accessed directly via the table list view (e.g., cmdb_ci_server_list.do),
so I can conditionally apply the filter?
Alternatively, is there another recommended approach to apply different filters
based on how the list view was accessed?
Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
you can do this
If the list is accessed directly via table navigation (e.g., cmdb_ci_server_list.do)
→ I want to apply a filter: manufacturer = VMware, Inc.
-> use Query business rule on that table and check the URL contains table_list and is not called via reference qualifier, if yes then apply filter for manufacturer
If the list is accessed via a reference field (e.g., u_server)
→ I want to show all records without any filter. -> apply reference qualifier and show all
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
you can do this
If the list is accessed directly via table navigation (e.g., cmdb_ci_server_list.do)
→ I want to apply a filter: manufacturer = VMware, Inc.
-> use Query business rule on that table and check the URL contains table_list and is not called via reference qualifier, if yes then apply filter for manufacturer
If the list is accessed via a reference field (e.g., u_server)
→ I want to show all records without any filter. -> apply reference qualifier and show all
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Thank you! I got a useful hint from your idea.
I applied the business query as shown below, and I confirmed that it's working as expected.
Just wanted to check — is it okay to keep using this approach moving forward?
Thanks again!
var url = gs.action.getGlideURI().toString();
var isReference = url.indexOf('sysparm_reference') !== -1;
var isListView = url.indexOf('_list.do') !== -1;
if (isListView && !isReference) {
current.addEncodedQuery('manufacturer.name=VMware, Inc.');
}