SNOW-CAD Practice Question: Automating application logic with business rules and scripts
A mid-sized company heavily relies on ServiceNow for incident management. They have a business rule that runs before insert on the Incident table. The rule dynamically sets the assignment group based on the category of the incident and the location of the caller. To determine the correct group, the script performs a GlideRecord query against a custom table called "u_group_mapping", which contains approximately 5000 records mapping category-location pairs to groups. During peak business hours, when many incidents are created simultaneously, the business rule causes significant delays and occasional timeouts, impacting user experience. The development team has been tasked with optimizing this business rule without changing its functionality. The current script structure is roughly: (function executeRule(current, previous) {
var gr = new GlideRecord('u_group_mapping');gr.addQuery('category', current.category); gr.addQuery('location', current.caller_id.location); gr.query();
if (gr.next()) {current.assignment_group = gr.assignment_group;
} })(current, previous);
The team wants to reduce the database access overhead. Which optimization technique should the developer implement?
⚠ Common exam trap
It's easy for candidates to confuse caching across sessions (Option B) with caching within a transaction (Option C), mistakenly thinking a global variable is more efficient, but ServiceNow’s architecture requires transaction-scoped caching to avoid stale data and concurrency conflicts.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Create a script include with a static variable to cache the mapping for the duration of the current transaction
Caching the mapping data in a static variable within a script include ensures that the GlideRecord query against the 5000-record custom table is executed only once per transaction, rather than on every incident creation. This drastically reduces database access overhead during peak hours, as subsequent invocations of the business rule within the same transaction reuse the cached results, eliminating redundant queries and preventing timeouts.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use GlideAggregate to retrieve the count of matching groups
Why it's wrong here
A count does not provide the assignment group needed.
- ✗
Store the mapping in a global script include variable that persists across sessions
Why it's wrong here
Global variables are not suitable for this purpose and can cause memory issues.
- ✓
Create a script include with a static variable to cache the mapping for the duration of the current transaction
Why this is correct
This caches the query results within the same request, reducing database calls.
- ✗
Move the business rule to run after insert so it does not block the insert
Why it's wrong here
This would change the behavior because the assignment group would not be set before the record is saved.
Go deeper
Related to this question
About these practice questions
One of 481 original SNOW-CAD practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This SNOW-CAD practice question is part of Courseiva's free ServiceNow certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SNOW-CAD exam.