Field Validation & Choice Lists
Consistent, validated data starts with the right constraints on every field. Learn field-level regex validation, how choice lists store and compare values, dependent picklists, and when to use a lookup table instead of a choice list.
Choice Lists — How They Work Under the Hood
A Choice field presents a dropdown of options on a form. These options are stored in the sys_choice table — one record per choice option. Each choice has four key attributes:
- Table — which table this choice belongs to
- Element — which field name on that table
- Label — what users see in the dropdown ("High," "New," "Pending")
- Value — what gets stored in the database ("1," "2," "3")
The label and value are deliberately separated. This allows ServiceNow to store compact values (integers, short codes) in the database while displaying human-readable labels in the UI. It also allows the label to be translated for different languages without changing the stored value.
1 for New, 2
for In Progress, 6 for Resolved, 7 for Closed.
Writing if (current.state == 'Resolved') will NEVER be true because
"Resolved" is the label, not the value. Always use current.state == 6.
Dependent Choice Lists
A dependent choice list filters the options of one field based on the current value of another field. The classic example in ServiceNow is Category → Sub-category. When you select "Software" as the Category, only Software-related subcategories appear. When you select "Hardware," only Hardware subcategories appear.
This is configured in the choice records themselves: each Sub-category choice record has a Dependent value field specifying which Category value it belongs to. The field also needs to be configured in the dictionary with a Dependent field pointing to the parent (Category) field.
sys_choice — they just have
an additional "Dependent value" populated. You manage them the same way as regular choices:
navigate to System Definition → Choice Lists, filter
by the child field, and you'll see all choices with their dependent values.
String Field Validation — Regex
For String fields where only certain formats are valid (phone numbers, IP addresses, postal codes, product codes), you can add a regular expression validation directly in the field's dictionary entry. If a user enters a value that doesn't match the regex, the save is blocked with a validation error.
To add regex validation: open the field's dictionary entry, scroll to the Attributes field or the dedicated Validation section, and enter the regex pattern. For example, to validate a US phone number: ^\+?1?\s*\(?[0-9]{3}\)?[-.\s]?[0-9]{3}[-.\s]?[0-9]{4}$
Managing Choice Lists
Choice lists are managed via two paths:
- Right-click the field on a form → Configure → Choice List — opens the choice editor for that specific field
- System Definition → Choice Lists — shows all choices for all tables, filterable by table/field
When you add a new choice, you specify: the table, the field name (element), the label, the value, the sequence (display order), and optionally a dependent value. Active checkbox controls whether the choice appears in the dropdown (inactive choices still exist but are hidden from the UI).
sys_choice
even when inactive, or existing records will show a blank/unknown value for that field.
Choice List vs. Lookup Table
For small, stable sets of options (5-15 values that rarely change), Choice Lists are the right tool. For larger, frequently-changing sets, or when each option needs additional metadata, a Lookup Table (standalone reference table) is better.
| Aspect | Choice List (sys_choice) | Lookup Table + Reference field |
|---|---|---|
| Who can add options | Developer (requires dictionary access) | Admin (add a row to the table) |
| Per-option metadata | Label + value only | Any additional fields you define |
| Size limit | Practical limit ~50 (performance/UX) | Thousands of rows if needed |
| Translation | Built-in label translation per language | Must build translation mechanism yourself |
| Cross-table reuse | One definition per table+field | One table referenced by many fields |
Common Exam Traps — Field Validation & Choice Lists
- Choice fields store the value (e.g.,
1), not the label (e.g., "New") — use values in conditions - Incident state values: 1=New, 2=In Progress, 3=On Hold, 6=Resolved, 7=Closed, 8=Cancelled
- Dependent choice lists filter Sub-category options based on Category — configured via "Dependent value" on choice records
- Regex validation on String fields blocks saves if value doesn't match — applies to forms AND APIs
- Deactivating a choice hides it from dropdowns but existing records still display it correctly
- Use Choice Lists for small stable sets; use Lookup Tables for large, changing, or metadata-rich option sets
Practice Questions
4 questions · Select an answer to see the explanation immediately.
A report filter uses "state = 'In Progress'" but returns no results, even though many incidents are in progress. What is the most likely cause?
B is correct. ServiceNow choice fields store numeric integer values in the database, not the display labels users see. For Incident state: 1=New, 2=In Progress, 3=On Hold, 6=Resolved, 7=Closed, 8=Cancelled. Filtering on the string "In Progress" finds nothing because the database contains "2". Scripts and conditions must always reference the stored value (integer), not the display label. Options A, C, and D describe unrelated issues — the root cause is the value-vs-label distinction.