Business Rule Before Query to show Correct Number of Rows is slowing down performance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 02:57 AM
We are using a business rule Before Query to solve the incorrect row-count problem brought by security constraints.
However, once the rule is enabled, the performance of the whole SPM module is seriously slowed down, causing more issues like finding a demand with the same sys_id when creating a demand via portal form.
We wrote the business rule according to this article: 6 Ways to Eliminate 'Rows Removed by Security Constraints' Message in ServiceNow - The SN Nerd;
This solution is also mentioned in official KB: Before Query Business Rules - The *Other* Access Control - Support and Troubleshooting
What could we do to enhance performance? It seems like the script cannot be further optimized.
Business Rule:
Security constraint row count problem:
After fixed:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 03:08 AM
Hi @SimKunW
It's expected. Please find below article which gives you more information.
https://www.servicenow.com/community/developer-articles/performance-best-practice-for-before-query-b...
Regards,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2025 03:19 AM
Before query business rules do have performance impact on that table.
Ensure your query business rule has interactive session check
!gs.hasRole('admin') && gs.isInteractive()
Also check this link which talks about how to improve performance
Performance Best Practice for Before Query Business Rules
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