OBLYTECH Logo
OBLYTECH Logo

Choice lists in ServiceNow: sys_choice records and how to manage

The sys_choice table holds one row per translated choice, keyed by the table and field the option belongs to. Each row holds a stored value, a label, a language code and a sequence number. Options are added and reordered through Configure Choices, while the empty entry and the display behaviour of a field are set through Configure Dictionary.

What the sys_choice table stores

Each row in the Choice table stores the translated text for one option. Because the table records which table and field the option belongs to, the same stored value can carry a different label in each language. The main fields are:

  • Table: the name of the table the translation applies to.
  • Element: the name of the field the translation is used for.
  • Language: a BCP 47 language code, such as tr for Turkish or es-MX for Spanish as used in Mexico.
  • Value: a key that stays the same across languages. The English label or a sequence number can fill this role, so that choices in different languages map to each other.
  • Label: the text shown for the choice in that language.
  • Sequence: a number that sets display order when the list should not run alphabetically.

The Choice Set table and one record per field

The Choice Set table, sys_choice_set, contains a record for each field that uses a choice list. Each record is tied to an application file, so update sets and team development can carry all the choices for one field inside a single update record. To open the table, enter sys_choice_set.list in the navigation filter.

A choice list does not support one-to-many selection, so a user picks one choice at a time.

Reading stored values in scripts

A script that checks a choice list needs the stored value of the option, not its label. On the incident table, the choice labelled Active is stored as the integer 2, so a check compares against 2. The Type field on the choice list’s dictionary entry determines the data type of these values. To find a value, right-click the field label, select Show Choice List, and locate the choice.

The None entry may not have a Choice row at all. A choice field set to None evaluates to an empty string in client-side scripts and to the string “0” in server-side scripts such as business rules.

Viewing choices with Show Choice List

Right-click the choice list field label and select Show Choice List to view its values. Change the filter at the top of the list to see other values. New choices are added through Configure Choices instead.

Viewing requires the personalize_choices role, and that role must be granted explicitly to the user. It cannot be an access control rule. When the role comes through an ACL on a particular field, the Show Choice List option does not appear, while Configure Choices still does.

Adding, reordering and removing options

Navigate to a form where the field appears. If the list depends on another field, enter the parent value first. For example, to customize the subcategories for the Hardware category on incidents, select Hardware in the Category field. Then right-click the field label and select Configure Choices. In the slushbucket, rearrange the order, add or remove items, or create new ones, and select Save. This action requires the personalize_choices role.

To add options at runtime, use the addOption method of the GlideForm API. Changes to choice options can affect business rules. Default Incident states are one example, so review the rules that read a list before changing its values. For a list already in use, deactivating options you no longer need avoids conflicts with existing data or scripts that rely on them.

Sharing one choice list across fields

Two fields in different tables can share one set of options. Right-click the label of the second field and select Configure Dictionary. Set the Choice table to the table where the first field resides, set the Choice field to the first field, and select Update. The second field then displays the first field’s values, and changes to them appear there too. This requires the personalize_choices role.

Removing the None entry

Navigate to a form where the field appears, right-click the field label, and select Configure Dictionary. Change the Choice field value to Dropdown without — None — (must specify a default value), then populate the Default field so a choice displays first. This requires the personalize_dictionary role. If the field depends on another field, the None option remains available.

Changing the label of the None entry

This needs the personalize_choices role, granted explicitly. Open Show Choice List from the field label, select New, and complete the form:

  • Element: leave the populated field name as it is.
  • Language: enter the language code for the label.
  • Sequence and Dependent value: leave empty.
  • Inactive: leave cleared.
  • Label: the text to show. JavaScript is allowed here, including calls to script includes. One example shows the instance time zone using gs.getSysTimeZone().
  • Value: enter NULL_OVERRIDE. Anything else makes the new label appear next to the — None — option instead of replacing it.
  • Hint: leave empty. The hint does not display when the field type is List (Glide List).

Deleting the choices for a field

To delete all choices for a field, open its record in sys_choice_set.list, check the box beside it, choose Delete from the Actions menu, and confirm. This requires the personalize role. This suits an application still in development. Once a list is in use, deactivating options is the safer route.

Creating a choice list on a field of another type

You can give an integer, string or reference field a choice list while keeping its original type. This needs the personalize_dictionary role. Navigate to All > System Definition > Dictionary, open the field’s entry, and change Choice to Dropdown with –None– or Dropdown without –None–. Right-click the form header and select Save, then click Create Choice List.

One choice is created for each unique value already in the field. If the field is empty, a single “– New choice –” entry is created. A reference field with a large number of records in its reference table cannot be converted, and it keeps displaying as a reference field.

Displaying a reference field as a choice list

Right-click the reference field label, select Configure Dictionary, and choose a Dropdown option under Choice List Specification. Save, open the Advanced view from Related Links, and add ref_auto_completer=AJAXReferenceChoice to the Attributes field, separated by a comma. Select Update.

Two system properties decide when the switch applies. glide.ui.max_ref_dropdown defaults to 25; above that many available choices, a reference icon shows instead. glide.xmlhttp.max_choices controls how many choices display, with a default of 15, and a hard-coded 10 when the property is missing.

Translating choice labels

To translate a choice, create a Choice record for each language you support. This needs the admin role. Navigate to All > System Localization > Choices, select New, and fill in Table, Element, Language, Label, Value and Sequence. For a Spanish label on the incident subcategory choice, the Language is es and the Value matches the English one.

Translated choices installed by a language plugin without a matching English record are set to inactive by default. If a plugin with English choices is activated later, its translations may not appear until those records are made active. Under All > System Localization > Languages, select an active language, then select Repair non-english sys_choice records in the Related Links section and confirm. A job runs 15 minutes later and sets the Inactive field of each translated record to match its English counterpart.

Limits and display settings

In the Australia release, choice list values can be up to 40 characters long, and numerical values must fall in the range of -999 to 999. For a long list, add is_searchable_choice=true to the Attributes field in the Advanced view of the dictionary entry, separated by a comma. This setting needs the admin role. By default, inactive or invalid values appear in blue text. To disable that colour indicator, go to All > System Properties > UI Properties and activate the check box for Display missing choice list entries.

Choice values on state fields

State fields are a subset of choice list fields, and the platform’s business rules read their numbers. A negative value adds an active state, such as Awaiting Vendor at -1 or -2. On the incident table, Closed is 7 and any state at 7 or above counts as inactive, so a new inactive state needs a positive integer above 7. On the change_request table, phase_state uses Complete at 8, so a new inactive state needs a value above 8.

The mark_closed rule is entered when an incident is resolved, so searching the Script and Condition fields for 6 and 7 shows which rules depend on them. Editing these numbers can change how tickets close and reopen.

Frequently asked questions

Why does Show Choice List not appear for me? Viewing that list needs the personalize_choices role granted explicitly. If the role arrives through an ACL on a particular field, the option is hidden, although Configure Choices still shows.

How do I remove the None entry from a choice list? Open Configure Dictionary for the field, change the Choice value to Dropdown without — None –, and populate the Default field. This needs the personalize_dictionary role.

Can two fields share the same set of choices? Yes. Point the second field’s Choice table and Choice field at the first field in Configure Dictionary, and it displays the first field’s options.

What are the length and range limits for choice values? In the Australia release, a choice value can be up to 40 characters, and numerical values must fall between -999 and 999.