Customizing Choice List Options

From SNCWiki

Jump to: navigation, search
Role required
Functionality described here requires the Admin role.
Fields

Contents

Overview

A choice list is a type of field that lets the user select from a pre-defined set of choices. It manifests as a normal HTML select field and should be instantly recognizable to anyone who has ever used a web browser.

Service-now.com makes it easy to customize the order in which items appear in a choice list, and also to add new items. As an example, to change the order of the Urgency choice list in the Incident form, right-click the field label and select "Personalize Choices".


You be taken to a table where you'll see the choice list's selections. There, you can rearrange the order, add or remove available items from the displayed list, and even create new items for the choice list.


Click "Save" when finished. Service-now.com automatically modifies the "Sequence" values of the choice list items so that they appear in the order you specified.


Choice list options with identical Sequence values are displayed alphabetically.


Changing the Maximum Number of Choices

The system has a default limit of 15 choices for any choice list. To change this, navigate to System Properties > System, and alter the property: The maximum number of items to show for a dynamic drop-down choice list.

Dependent Choice Lists

If your choice list is dependent on the content of another field, you'll need to first enter into that field the value you want to work with. For example, to customize Subcategory choice list entries for the Hardware category, first set the category on the form to "Hardware". Then perform the actions described above.


Removing the -- None -- option from a choice list

If you wish, you can give it a "Choice" type of "Dropdown without -- None --", which will remove the "-- None --" option from the choice list. Note that you must give your choice list a default value, and the field must not be dependent on another field, otherwise the None option will remain.


Changing the -- None -- display value for a choice list

In this example, we'll show you how to change the default display label of a choice list from "--None--" to "--Choose--". You can use this method to change it to whatever text you want.

To change the default display label of a choice list, right-click the choice list field's label and select Show Choice List. You will see a list of choice list items in the dictionary. Click New.


Set the Label to "--Choose--" (or whatever you want the default to be). Next, set the Value to NULL_OVERRIDE. (This step is critical...it's what tells Service-now.com to override the hardcoded default display of "--None--". If you don't set the Value to NULL_OVERRIDE, then both "--None--" and "--Choose--" will appear in your choice list.)


Click Submit when finished. You'll now see your new default display label instead of "--None--".

Image:ChoiceListAfter.png


The Label value may even contain a Javascript that evaluates to the label (optionally, you may call a global business rule function in the Javascript). For example, the following screenshot depicts the overriding of the Time-zone choice list default null value in a user record. The label is evaluated to the time-zone value of your Instance.

Image:def_null_label_choice.png


Displaying inactive or invalid choice list values

By default, inactive or invalid choice list values are displayed with blue text instead of black. For example, in the screenshot below, the Network category has been deactivated. It appears in the list for records that still hold that value, to indicate that those records indeed have a value, even though an invalid one:

Image:ChoiceListInvalid2.png


This behavior is controlled by a property. To change it, navigate to System Properties >UI Properties, and look for the following property:

Image:ChoiceListInvalid1.png


Customizing integer choice list values

While you can customize Choice List values for fields such as incident_state, state, problem_state, etc., some care is advised. There are several out-of-box business rules whose behavior is dictated by these values. For example, a business rule on Incident might set the Active flag to false when the Incident state field's value changes to 7 (the value for the "Closed" Incident state). If you change the values of your Incident state options, this business rule might no longer behave as desired or expected.


The following is a description of out-of-box choice list fields affected by out-of-box business rules whose behavior is dictated by the fields' values.

  • For incidents, the three fields of note are Active, State, and Incident state. The following out-of-box business rules work with these field. They run in the order shown:
    • mark_closed (incident) - if the incident_state changes to 7 (Closed), the active flag is set to 'false'
    • incident reopen (incident) - if the incident_state is less than 7 (Closed), and the active flag is 'false', the active flag is set to 'true'
    • mark closed (task) - if the state changes to either 3 (Closed Complete) or 4 (Closed Incomplete), the active flag is set to 'false'
    • task closer (task) - if the active flag changes from true to false, and the state is neither 3 (Closed Complete) nor 4 (Closed Incomplete), the state is set to 3 (Closed Complete)
    • task reopener (task) - if the active flag changes from false to true, and the state is either 3 (Closed Complete) or 4 (Closed Incomplete), the state is set to 1 (Open)
Note
Note: In the above list, notice there are no business rules that change incident_state based on a change to either the active flag or the state field. Changes to incident_state drive the other two fields, not the other way around.

Determining values associated with choices for use in scripting

If you are writing a script that reference a value in a choice list you will probably need to know the value associated with choices there. For example if you are writing a script that checks the incident state field to see if an incident state is active, something like (current.incident_state == "active") will not work because the value associated with the choice "Active" is not acutally the string "Active". Rather it is a string "2".


It is important to note that all choice values are stored as strings even when they are numbers!


To determine the value associated with a particular choice in a choice list follow these steps:

  • Right click on the label associated with choice field and select "Show Choice List"

Image:Personalize_choices.png

  • Find the choice you need to reference the value for. The string that the field will evaluate to if referenced in script is contained in the value field.

Image:shown_choices.png

Remeber that the value is always a string even when its a number!

Values associated with the "None" option

The "None" option does not have a sys_choice record associated with it and so will not show up in the list like in the screenshot above. A choice list field set to "None" will evaluate as follows depending on the context of the script being used:

  • Client script: "" (empty string)
  • Business rule "0" (string of the number zero)


Adjusting Choice List Width

The width of choice lists is controlled by a property (glide.ui.choicelist.defaultwidth). This can be found in System Properties > UI Properties under the setting for "Default choice list width (pixels)". The default is 160 pixels. This can be set to a larger number if needed. Note this will change the width of all choice lists on the instance.

Sometimes there is a choice list with unusually long items in it. In these cases, you may want to adjust the size of the choice list to the content and not cause all the other choice lists to be resized. A Field Style can be used to accomplish this. Right-click on the field's label and choose "Personalize Styles". Click the "New" button to create a new style, leave the "value" blank (so it applies to all the choice values regardless of which is selected), and enter the style "width:auto".

Personal tools
Print/export