SNOW-CSA UI, Navigation and Forms Practice Question
Exhibit
Refer to the exhibit.
```
// UI Policy Condition Script - Incident table
// This script runs onLoad
(function executeRule(current, previous !=null) {
if (current.state == 2) { // In Progress
g_form.setMandatory('short_description', true);
}
})();
```Refer to the exhibit. The UI Policy script above is meant to make the Short Description field mandatory when the incident state is 'In Progress'. However, it does not work. What is the most likely reason?
⚠ Common exam trap
ServiceNow often tests the distinction between client-side and server-side objects, and the trap here is that candidates mistakenly think `previous` is available in UI Policy scripts because it is commonly used in business rules, leading them to overlook the syntax error.
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
✓
There is a syntax error in the function parameters: 'previous !=null' is invalid
The condition `previous != null` is invalid syntax in a UI Policy script. UI Policy scripts run on the client side and do not have access to the `previous` object, which is only available in server-side business rules. The correct approach would be to check the current state of the `state` field using `g_form.getValue('state')` or similar client-side methods.
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 method 'g_form.setMandatory' is deprecated
Why it's wrong here
'setMandatory' is a valid method.
- ✗
The script is blocked by the 'glide.script.secure' property
Why it's wrong here
No such property by default.
- ✓
There is a syntax error in the function parameters: 'previous !=null' is invalid
Why this is correct
The correct is 'previous' without the comparison.
- ✗
The script uses 'current' object which is not available in client scripts
Why it's wrong here
Although 'current' is not directly available in client-side UI policies, the script would still run but might not get the state correctly; however the syntax error is the main issue.
Go deeper
Related to this question
About these practice questions
One of 504 original SNOW-CSA 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-CSA 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-CSA exam.