SNOW-CAD Practice Question: Automating application logic with business rules and scripts
Which two of the following are best practices when writing Script Includes in ServiceNow? (Choose two.)
⚠ Common exam trap
ServiceNow often tests the misconception that all code should be wrapped in try-catch for error handling, but in ServiceNow, this is not a best practice because it can hide logic errors and is rarely needed due to the platform's built-in error logging and transactional rollback.
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
✓
Avoid using GlideRecord queries inside loops to prevent performance issues.
Running GlideRecord queries inside loops (e.g., for or while) causes multiple database round-trips, which severely degrades performance, especially with large datasets. Instead, you should use GlideRecord's query() once and iterate over the result set, or use GlideAggregate for aggregated calculations to minimize database calls.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Keep the script source code under 10 KB to improve performance.
Why it's wrong here
Script size is not a primary factor; efficiency of logic matters more.
- ✗
Wrap all code in try-catch blocks to handle errors gracefully.
Why it's wrong here
Overusing try-catch can hide bugs; only use where necessary.
- ✗
Use gs.addInfoMessage() to output debug information while developing.
Why it's wrong here
gs.addInfoMessage() shows messages in the UI, not in logs; use gs.log() for debugging.
- ✓
Avoid using GlideRecord queries inside loops to prevent performance issues.
Why this is correct
Queries inside loops cause multiple database calls; use batch processing or GlideAggregate.
- ✓
Use GlideAggregate instead of GlideRecord for aggregation calculations like count or sum.
Why this is correct
GlideAggregate performs aggregation at the database level, reducing data transfer.
Go deeper
Related to this question
About these practice questions
This SNOW-CAD question is part of Courseiva's 481-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. 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.