Courseiva
Creating and customizing tables and datamediumMultiple ChoiceObjective-mapped

SNOW-CAD Creating and customizing tables and data Practice Question

Exhibit

Refer to the exhibit.

Table: u_custom_asset
Fields:
  u_asset_tag: string (max length 50)
  u_serial_number: string (max length 100)
  u_model: reference to cmdb_model
  u_cost: currency

Business rule: Before insert on u_custom_asset
Script:
(function executeRule(current, previous /*null when async*/) {

    if (!current.u_asset_tag) {
        var gr = new GlideRecord('u_custom_asset');
        gr.addQuery('u_asset_tag', 'CONTAINS', 'AST-');
        gr.orderByDesc('sys_created_on');
        gr.query();
        if (gr.next()) {
            var lastTag = gr.u_asset_tag.toString();
            var num = parseInt(lastTag.substring(4)) + 1;
            current.u_asset_tag = 'AST-' + num;
        } else {
            current.u_asset_tag = 'AST-1000';
        }
    }

})(current, previous);

A developer created the business rule shown in the exhibit to auto-generate asset tags. However, when a new asset is created, sometimes the generated tag is a duplicate of an existing tag. What is the most likely cause?

⚠ Common exam trap

ServiceNow often tests the subtle flaw of using 'CONTAINS' for numeric suffix extraction, where candidates overlook that substring matching can return unintended records, and assume ordering by creation time is sufficient for determining the highest number.

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 query uses 'CONTAINS' which may match unintended tags, and ordering by sys_created_on may not guarantee the highest number

The script uses a glide query with 'CONTAINS' to find the highest existing asset tag number, which can match unintended tags (e.g., 'TAG-10' matching 'TAG-1001'), and ordering by 'sys_created_on' does not guarantee the highest numeric suffix. This leads to duplicate tags when the generated number is already in use but not detected as the maximum.

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 condition '!current.u_asset_tag' fails when the field is empty

    Why it's wrong here

    Empty string is falsy, so condition works.

  • The script does not account for records with null asset tags

    Why it's wrong here

    It queries existing tags.

  • The script does not handle the scenario when no asset tag exists

    Why it's wrong here

    It sets 'AST-1000' if no tag found.

  • The query uses 'CONTAINS' which may match unintended tags, and ordering by sys_created_on may not guarantee the highest number

    Why this is correct

    CONTAINS can match multiple patterns, and ordering by creation time may not reflect the highest number.

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.