Courseiva
Working with DatahardMultiple ChoiceObjective-mapped

SNOW-CAD Working with Data Practice Question

A developer is writing a scripted REST API endpoint that returns a list of users. The requirement is to return only users who are in the 'IT' department and have a role of 'itil' or 'admin'. The endpoint uses GlideRecord. Which query condition is most efficient?

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

gr.addQuery('department', 'IT'); gr.addQuery('role', 'itil'); gr.addOrCondition('role', 'admin');

It uses addQuery('department', 'IT') to filter by department, then addQuery('role', 'itil') and addOrCondition('role', 'admin') to create an OR condition for roles. This ensures only users in the IT department with either the itil or admin role are returned efficiently using GlideRecord's built-in OR logic. Option B is wrong because it only returns users with both department IT and role itil, missing those with role admin. Option C is wrong because it's inefficient to query all IT department users then iterate to check role in script; better to use an encoded query or OR condition directly. Option D is wrong because passing 'itil,admin' as a single string would be interpreted as a literal value, not an OR condition; GlideRecord would look for users whose role field equals exactly 'itil,admin', which is incorrect.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • gr.addQuery('department', 'IT'); gr.addQuery('role', 'itil'); gr.addOrCondition('role', 'admin');

    Why this is correct

    Correctly uses addOrCondition for OR within the same department condition.

  • gr.addQuery('department', 'IT'); gr.addQuery('role', 'itil');

    Why it's wrong here

    Uses AND, not OR; will return only users with both roles if user has multiple roles, but not correct for OR.

  • gr.addQuery('department', 'IT'); gr.query(); then iterate and check role.

    Why it's wrong here

    Less efficient because it retrieves all IT users and then filters in script.

  • gr.addQuery('department', 'IT'); gr.addQuery('role', 'itil,admin');

    Why it's wrong here

    Comma-separated values are not treated as OR; they are treated as a single string.

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 →

How Courseiva writes practice questions · Editorial policy

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.