CIS-ITSM practice question 18 of 25

The current status of a problem record is tracked in the State field. Each state has a label, value and constant. This example is for Fix in Progress state: Your customer wants to add a prerequisite for moving out of the Fix in Progress state. When you update the script include which value is better to use in the script?

Full set: 172 questions
Answer options
A: 104
B: "Fix in Progress"
C: ProblemState.STATES.FIX_IN_PROGRESS Correct answer
D: 104.ProblemState.STATES.FIX_IN_PROGRESS
Correct Answer:
C. ProblemState.STATES.FIX_IN_PROGRESS
Explanation

Using the constant ProblemState.STATES.FIXINPROGRESS is the ServiceNow best practice for scripting. This approach makes the code more readable and maintainable. It abstracts the underlying integer value (104), so if the value changes in the future (e.g., during a system upgrade or customization), the script will not break. The logic remains tied to the constant's meaningful name, and only the central ProblemState script include would need to be updated, ensuring system-wide consistency.

Why Incorrect

A. 104: This is a "magic number." Using hardcoded integer values makes code difficult to read and maintain. If the state value changes, the script will fail.
B. "Fix in Progress": Using the display value string is unreliable. It can change due to administrative preference or language translation, which would break the script logic.
D. 104.ProblemState.STATES.FIXINPROGRESS: This is syntactically incorrect and not a valid way to reference an object property or constant in JavaScript.

References

1. ServiceNow Developer Documentation - Coding best practices: In the "Server-side scripting" section, it advises against hardcoding values. "Avoid hard-coded sysids and magic numbers. Do not hard-code sysids, table names, or other values in scripts. Instead, use a property or a script include to store and retrieve the value." This directly supports using a constant from a script include (Option C) over a magic number (Option A).

2. ServiceNow Product Documentation - ProblemStateSNC script include: This official documentation describes the read-only script include that defines the constants for problem states. It lists constants such as DRAFT, ASSESS, ROOTCAUSEANALYSIS, FIXINPROGRESS, etc., confirming their intended use in scripts to refer to problem states. This validates that ProblemState.STATES.FIXINPROGRESS is the correct and intended method.

Scroll to Top