Mobile Element Select Options

Select Element Options

Basic Properties

The options available for selection within a select (or multi-select) type field on the Field Service Management mobile app can be configured using the "options" property. This property should be provided an array of valid options, each of which should have an "id" and a "label" property.

For example a basic list of options may look like this:

            "options": [{
  "id": "1",
  "label": "Option 1"
},{
  "id": "2",
  "label": "Option 2"
},{
  "id": "3",
  "label": "Option 3"
}] 

          

The "selected" Property

Each option can also be set with an optional "select" property which can be used to evaluate which option is selected by default. The option with the lowest value set in it’s "select" property will be selected as the default value. In the example below the “Apple” option will be selected by default.

            "options": [{
  "id": "333",
  "label": "Bannana",
  "selected": "3"
},{
  "id": "555",
  "label": "Apple",
  "selected": "1"
},{
  "id": "777",
  "label": "Orange",
  "selected": "2"
},{
  "id": "999",
  "label": "Mango"
}] 

          

Notice that not all options must have a "selected" property. Of those that have a value set, the one with the lowest value is then set as the default option.

This may not seem very useful when hard-coding a list of available options but it does become handy when the options list is generated as the result of a search. Below the "custrecord_nx_case_type" search is first run and then the results of that search are set as the options available to the select field.

            "options": {
  "record": "customrecord_nx_case_type",
  "filters": ["isinactive","is","F"],
  "map": {
    "id": "internalid",
    "label": "name",
    "selected": "formulatext: CASE WHEN {internalid} IN (1) THEN '1' WHEN {internalid} IN (3) THEN '2' END"
  }
} 

          

The basic formula above means that the case type with internalid 1 will be selected as the default value if it is found to be a result of the search. If it is not found, then the case type with internalid 3 will be selected instead. If neither case type is found then no default option will be selected.

Additional Properties

Additional properties can be arbitrarily added to the options in a select field. These additional properties will also be available to the search function of the current element; search terms will be compared against the "id", "label" and any other additional property value added to the options.

            "options": [{
  "id": "1",
  "label": "Option 1",
  "altname": "opt1"
},{
  "id": "2",
  "label": "Option 2",
  "altname": "opt2"
},{
  "id": "3",
  "label": "Option 3",
  "altname": "opt3"
}] 

          

The options above will allow the user to also search for those options using the alternate names “opt1”, “opt2” and “opt3” even though these alternate names aren’t displayed as the label of any option.

Note:

When a value is selected within an element on the mobile, only the "id" and "label" properties will be copied across to the "value" property of the element. Dynamic expressions can be used to lookup any additional properties of the selected value by matching the id against the options list.

For example, see the element below where the "selectedunitcode" property pulls out the "unitcode" of the currently selected option.

            "selectelement1": {
  "type": "select",
  "label": "Select Element 1",
  "options": [{
    "id": "1",
    "label": "Option 1",
    "unitcode": "555"
  },{
    "id": "2",
    "label": "Option 2",
    "unitcode": "777"
  },{
    "id": "3",
    "label": "Option 3",
    "unitcode": "999"
  }],
  "selectedunitcode": "selectelement1.value && selectelement1.options.find(o => o.id == selectelement1.value.id).unitcode"
} 

          

General Notices