SNOW-CAD Practice Question: Application development using ServiceNow Studio
Exhibit
var gr = new GlideRecord('incident');
gr.get('number', 'INC001234');
gr.setValue('state', 2);
gr.update();Refer to the exhibit. What does this script do?
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
✓
Updates the state of incident INC001234 to 2.
The script retrieves the incident with number 'INC001234' using `get('number', 'INC001234')`, which returns a GlideRecord object. The `get` method returns true if the record exists and loads it into memory. Setting `state` to 2 (which corresponds to 'In Progress' or a similar value) modifies the record, and `update()` commits the change to the database. Option A is incorrect because `get` returns true if the record is found, so it does do something. Option C would require using `insert()` after setting values, but not `get`. Option D would require `deleteRecord()`, not `update()`.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Does nothing because get returns false.
Why it's wrong here
If the record exists, get returns true and the update proceeds.
- ✓
Updates the state of incident INC001234 to 2.
Why this is correct
The script uses get() to fetch the record, setValue to change state, and update() to save.
- ✗
Creates a new incident.
Why it's wrong here
No insert() call; it only updates an existing record.
- ✗
Deletes the incident.
Why it's wrong here
There is no delete operation.
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.