Courseiva
Self-Service and AutomationmediumMultiple ChoiceObjective-mapped

SNOW-CSA Self-Service and Automation Practice Question

Exhibit

Refer to the exhibit.

Catalog Client Script (onChange) on variable 'category':
```javascript
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue == '') {
      return;
   }
   var subcat = g_form.getControl('subcategory');
   if (newValue == 'hardware') {
      subcat.setOptions({laptop: 'Laptop', desktop: 'Desktop'});
   } else if (newValue == 'software') {
      subcat.setOptions({os: 'Operating System', office: 'Office Suite'});
   }
}
```

A catalog item has a variable 'category' (choice) and 'subcategory' (select box). When a user selects 'hardware' for category, the subcategory dropdown shows laptop and desktop. When 'software' is selected, it shows Operating System and Office Suite. However, users report that after selecting category, the subcategory dropdown does not update. What is the most likely cause?

⚠ Common exam trap

Many exam-takers assume `g_form.getControl` can be used to set options by manipulating the DOM directly, but ServiceNow requires the specific `setOptions` API to update variable choices, and using `getControl` will silently fail to update the dropdown.

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 incorrectly uses g_form.getControl instead of g_form.setOptions on the variable

The script must use `g_form.setOptions()` to dynamically update the choices of a select box variable (subcategory) based on the selected category. Using `g_form.getControl()` only retrieves the DOM element but does not modify the variable's options; it is typically used for UI manipulation like disabling or styling, not for updating choice lists. The failure to call `setOptions` means the subcategory dropdown never receives the new list of options, so it remains unchanged.

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 'subcategory' variable is not a select box but a reference field

    Why it's wrong here

    The problem states it's a select box.

  • The script returns on isLoading, which prevents the update

    Why it's wrong here

    Returning on isLoading is standard to avoid updates on page load.

  • The script incorrectly uses g_form.getControl instead of g_form.setOptions on the variable

    Why this is correct

    The correct method is g_form.setOptions('subcategory', ...) to update the choice list.

  • The onChange event is not triggered because the category field is a choice list

    Why it's wrong here

    Choice fields do trigger onChange.

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 →

How Courseiva writes practice questions · Editorial policy

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.