Choices
Summary
Within the platform, one of the field types that can be created is a choice field. These fields assist in allowing users to select from a per-defined list of values, without referring to a specific Table. These labels can be localised, can be scripted and can use the same group of choices across multiple entities and fields.
How choices are stored
Although choices are not stored within bespoke entities, they are stored in a specific Table. We do not have to interact with it directly (as in most situations you can simply do it via the field definition as described in Choices | Method of choice creation and modification ). For more advance usages of choices however, it is important to understand how they are stored and how they can be manipulated directly if required.
Available value
The available value Table stores the the key and label combination that make up the content of a choice list. When you are configuring a field definition for a choice field, these are the records that are created, updated and deleted based on what you do from the field specific settings tab.
Field | Type | Example | Notes / Description |
---|---|---|---|
Table | Reference | Incident | This is the table where the Available value will appear as a choice |
Field | Reference | Impact | This is the field (on the configured Table above), where the Available value will appear as a choice |
Key | String | 1 | This is the key of a choice that is used when getting the value of a choice field. When scripting or otherwise, this is what needs to be used when setting values or querying values. This does not support special characters outside of underscores (_), so it is often recommend to make your keys alphanumeric with spaces being replaced with underscores. It does not need to match the label. |
Label | Localised text | P1 | Critical | This is what people will see when selecting a choice from a choice field. These are localised text values, so in situations where multi language is required, these label can be different per language. This is the display value of each choice. |
Group | String | ITSMWorkPriority | The group field is used to group certain values together. This is the field that is referenced within the Table available field values Table, to tie various values to a field and Table combination. This separation of entities, is what allows you to use the same group of available values within multiple field and Table combinations. |
Icon | Icon selection | Forward to Inbox | This allows you to select from a list of icons in the system that you want a specific choice value has. |
Styles | Multi Reference to named styles | status dot, status dot red | This allows you to select any named styles you have defined or out the box that you want to have for individual choice options. |
CSS | String |
| This is a reference to a CSS style that is defined either in the system or style sheet. This can be used to add a style to individual choice options. |
Active | Boolean | True | This determines if a choice can be selected from a choice field. Often when choice values are no longer needed, they are kept (not deleted), but made inactive to ensure data integrity. |
Order | Integer | 100 | This determines what order the choices of the same group are displayed as. The ordering essentially goes from the lowest to highest choices, however what the numbers are does not matter. If you had 1 available value with an order of 1 and another with 2, this would display the same as if the value had the order of 1 had an order of 100 and the other value had an order of 2500. |
Value type | Choice | Standard | Choices are:
You can group choices together with the purpose of re-using them across multiple choice fields. To do that, set the Value type to be “Group”. |
Group | String | ITSMWorkPriority | The group field is used to group certain values together. With This is the field that is referenced within the Table available field values Table, to tie various values to a field and Table combination. This separation of entities, is what allows you to use the same group of available values within multiple field and Table combinations. |
Qualifier | String |
| This is an optional field which is used to display/hide a choice dependant on another field’s value. E.g. if a Choice field selection is to drive another Choice field’s available options. For more information, please refer to Choices | Choice field dependant of another field |
Method of choice creation and modification
When you create a choice field, there are a few different ways that the choices within that field can be populated. Each of them have their purposes and have their benefits. However often the basic usage is required. No matter what method you use, you can switch them depending when / if your requirements change. It should be noted that this is a system administrator task and these values cannot be modified by non administrator users.
On field creation
When creating a choice field, it allows you to select from an existing value group, or creating your own.
Version 1.10:
After selecting a field type of “Choice”, you will be presented with the “Available values” section where you can configure the choices for the Choice field. You can add / remove / reorder your choices as required.
You can enable the Advanced mode by checking the checkbox that will also show the Order number and the Key.
Before Version 1.10:
After selecting a field type of “Choice”, you will be presented with the “Available values” section where you can configure the choices for the Choice field. Filling in the Choice label will auto populate the Choice key, but you will need to provide the Order number for the choice/available value entry. Once you added a choice to the list, it will show up in the box on the bottom half, below the Add/Update button.
After field creation
If you want to modify these choices after creating a field, this can be done by going to the form where the choice field is and right clicking the field and following the steps below. It should be noted that this will look up the available values of Standard type that is configured for the Table field. Using this method means you do not need to interact with the Available value table directly and allows you to maintain simply choice lists within a few clicks.
Version 1.10:
Right click on field label and left click on “Edit available values”
You will see a pop-up screen with the currently configured available values. You can then add/reorder/update/remove the choices as required. Example below:
To update, select an existing choice, and then update the Choice label, while to change the order, you can also drag the configured options up and down.
Before Version 1.10:
Right click on field label and left click on the “Show definition” menu item. You can then add/reorder/update/remove the choices as required. Example below:
To update/change order, select an existing choice, and then update the Choice label and/or the Order.
Same group, different field
In situations where you have a select of available values you want to use for multiple fields that can be across different entities, this is done by modifying the field’s properties. For example below, is for out of box field “ExternalSource” on the CMDB table where it is making use of Available value options with Group name of “CMDBExternalSourceGroup”.
The properties are:
Property name | Example value |
---|---|
available_value.group | CMDBExternalSourceGroup |
available_value.type | group |
Different choices per Table for the same field.
In situations where you have a field on a base Table, but then want different choices on an extended Table, such as a priority field on Incident, where as the field exists on the ITSMWork level, you can do this by creating new available value directly on the field definition.
First go to the field on the form, e.g. Priority on Incident, right click on the field label to show the field definition and then go to the “Field specific settings” tab. If the field’s available value has been configured in the parent table or higher in the hierarchy, the tab will present like below where it gives you the option to create new choices for the lower level table:
Usage
Choice field dependant of another field
A choice field can be configured to be dependent on another field like a choice field or a reference field. To configure the dependency, please follow the following steps.
Note that we are using an example if there are two choice fields called “Business area” and “Type” where what you choose as Type, drives what is available to be selected on the “Business area” choice field.
Add a field property to the choice field you want to be dependent on the other field.
Property name | Value |
---|---|
dependent.on | *Field name that the choice field is dependent on |
Go to the form layout configuration and click on the Configure icon on the same choice field that you want to be dependent on the other field. You will be presented with the settings for that field on that particular form layout. You need to set the below, under the “Advanced options” section:
Option | Value |
---|---|
Field value type | Dependant field |
Dependant fields | *Field name that the choice field is dependent on |
Dependant field action | Recalculate available field values |
Then, on each the choice field’s available value record, populate the Qualifier field with the value of the other field (that the choice field is dependent on), that will result in the choice field’s available value showing.
Continuing with our example, if we only want to show Business area option called “Area 51” when Type “Issue” is selected, but “Area 1” when Type “Request” is selected:
Then, you would want to update the Qualifier for the “Area 51” and “Area 1” Available value records to point to the “Type” values that you want. Example below shows the “Area 51” Available value to show the behaviour as shown in screenshot above:
Note that what you put in the Qualifier field needs to be the actual value, not the label. So, being dependant on another choice field, you will need to put in the dependant choice field’s Key. In this example, the label is “Issue”, but the Key is “issue”.
If your field is dependent on a reference field, then what you need to put into the Qualifier field needs to be the ID of the referenced record.
Related content
Servicely Documentation