- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2025 05:41 AM
Hello ServiceNow Community,
I am trying to implement a customization in a best-practice way by avoiding the modification of an out-of-the-box (OOTB) Business Rule. I've encountered an issue where my new Business Rule seems to be ignored.
My goal is to allow a specific custom role, inactive_user_viewer, to view all users on the sys_user table, including those who are inactive.
Here is my approach:
I have not modified the OOTB Business Rule named "user query." It is still active with its default logic.
I created a new before query Business Rule on the sys_user table. I set its Order to 110 to ensure it runs after the OOTB rule (which has an order of 100).
My expectation was that my new rule, running later in the order, would override the OOTB filter for users with my custom role. However, the OOTB rule's filter is still being applied, and users with the inactive_user_viewer role cannot see inactive users.
Could you please provide some insights into why this setup might not be working? Is there a reason a second before-query rule cannot effectively override the query created by a previous one?
Here are the details of my configuration:
OOTB "user query" Business Rule (Active):
Table: sys_user
Order: 10,000
Condition: gs.getSession().isInteractive() && !(gs.hasRole("admin") || gs.hasRole("user_admin"))
Script: (Default OOTB script that adds the active=true filter)
My New Business Rule:
Name: Custom BR
Table: sys_user
Order: inactive_user_viewer
Condition: !(gs.hasRole("inactive_user_viewer"))
Script: (Default OOTB script that adds the active=true filter)
I would appreciate any guidance on how to properly implement this solution while adhering to best practices and not modifying the OOTB rule.
Thanks a lot!
Best,
Firat
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2025 06:05 AM
both the business rules will run and append the query and the queries will be combined, so inactive users are still not visible.
Approach 1
-> You need to modify the OOTB query business rule so that it doesn't run for your role user and keep your other query BR
gs.getSession().isInteractive() &&
!(gs.hasRole("admin") || gs.hasRole("user_admin") || gs.hasRole("inactive_user_viewer"))
OR
Approach 2
-> Deactivate the OOTB one and handle everything in your query BR the OOTB logic and your new logic
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
07-28-2025 06:05 AM
both the business rules will run and append the query and the queries will be combined, so inactive users are still not visible.
Approach 1
-> You need to modify the OOTB query business rule so that it doesn't run for your role user and keep your other query BR
gs.getSession().isInteractive() &&
!(gs.hasRole("admin") || gs.hasRole("user_admin") || gs.hasRole("inactive_user_viewer"))
OR
Approach 2
-> Deactivate the OOTB one and handle everything in your query BR the OOTB logic and your new logic
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
07-29-2025 12:18 AM
Hi Ankur, thank you for your reply.
If the query is appended, I have the same query (inactive=false) for both business rules, it should just then work for the new BR, no? I only changed the condition and added a new one !gs.hasRole("inactive_user_viewer")) .
Best,
Firat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2025 12:32 AM
the OOTB query is active=true so it gets appended with your Query BR condition.
I already shared the 2 approaches.
Please discuss with your Architect and Customer and accordingly proceed.
I believe I have answered your question.
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