Courseiva

SNOW-CAD Practice Question: Automating application logic with business rules and scripts

Exhibit

var MyUtils = Class.create();
MyUtils.prototype = {
    initialize: function() {},
    getTotal: function(table, query) {
        var ga = new GlideAggregate(table);
        ga.addQuery(query);
        ga.addAggregate('SUM', 'amount');
        ga.query();
        if (ga.next()) {
            return ga.getAggregate('SUM', 'amount');
        }
        return 0;
    },
    type: 'MyUtils'
};

Refer to the exhibit. A Business Rule in the same scope calls this script include using 'var total = new MyUtils().getTotal("invoice", "state=paid");' but gets '0' even though there are records. What is the most likely cause?

⚠ Common exam trap

ServiceNow often tests the misconception that a GlideAggregate query syntax error is the cause, when the real issue is a non-numeric field type that prevents aggregation from returning a valid sum.

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 'amount' field is not numeric in the invoice table.

The Business Rule calls `getTotal` which uses `GlideAggregate` to sum the `amount` field. If the `amount` field is not numeric (e.g., it is a string or another non-numeric type), `GlideAggregate.addAggregate('SUM', 'amount')` will return `0` because it cannot perform a numeric aggregation on non-numeric data. This matches option B.

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 getTotal method is not properly defined.

    Why it's wrong here

    Method is correctly defined.

  • The 'amount' field is not numeric in the invoice table.

    Why this is correct

    Non-numeric field causes SUM to return null.

  • The GlideAggregate query syntax is incorrect.

    Why it's wrong here

    Encoded query is valid.

  • The script include is not accessible from the Business Rule's scope.

    Why it's wrong here

    Same scope, no access issue.

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.