SNOW-CAD User Interface Development Practice Question
Exhibit
Refer to the exhibit.
Server script in a Service Portal widget:
(function() {
var gr = new GlideRecord('incident');
gr.addQuery('active', true);
gr.query();
var count = 0;
while (gr.next()) {
count++;
}
data.count = count;
})();A developer runs this widget server script and expects data.count to be the number of active incidents. However, the widget displays 'undefined' for data.count. What is the most likely cause?
⚠ Common exam trap
ServiceNow often tests the requirement for explicit function parameters in widget server scripts, trapping candidates who assume data is globally accessible or who focus on GlideRecord syntax errors instead of the missing parameter signature.
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
✓
The script is missing the function parameters (options, data) that provide the data object.
In ServiceNow widget server scripts, the function signature must include the parameters (options, data) to access the data object that is passed to the client script. Without these parameters, the data variable is undefined, causing data.count to display 'undefined'. The script likely defines the function without parameters or with incorrect ones, so the data object is not available.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The addQuery method syntax is incorrect; it should use a condition string.
Why it's wrong here
addQuery('active', true) is valid syntax.
- ✗
The while loop uses next(); it should use hasNext() instead.
Why it's wrong here
next() is correct to iterate.
- ✓
The script is missing the function parameters (options, data) that provide the data object.
Why this is correct
Without parameters, data is not defined in the closure.
- ✗
GlideRecord requires an initialize() call before query.
Why it's wrong here
GlideRecord constructor initializes the object.
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 →
Same concept, more angles
1 more way this is tested on SNOW-CAD
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A service portal widget is supposed to load data from a table and display it in a list. The widget renders but shows no data. Which is the most likely cause?
medium- A.The table's ACL denies read access to the user.
- B.The widget's client script has a syntax error.
- C.The portal page is not configured to include the widget.
- ✓ D.An error in the widget's server script prevents data from being queried.
Why D: The widget renders (client-side works) but shows no data, indicating the server-side script that queries the table failed. Option A (ACL denial) would typically show an error or empty data but is less common than a script error. Option B (client script syntax error) would affect interactivity, not initial data load. Option C (portal page not configured) would prevent the widget from rendering entirely.
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.