Configuring FSM Mobile Number Elements
This topic is intended for administrators and developers who configure Number elements in Field Service Management (FSM) Mobile.
In FSM Mobile, use a number element for whole numbers, decimal measurements, currencies, percentages, and other numeric values. Configure precision, increments, and units for the required behavior. The integer, float, currency, and percent aliases resolve to number. For more information, see Element Type Aliases and Compatibility Types.
This topic includes the following sections:
The following table lists recommended configurations for common numeric values and the resulting behavior.
|
Usage Pattern |
Recommended Configuration |
Result |
|---|---|---|
|
Whole numbers |
|
Limits entry and display to whole numbers. |
|
Decimal measurements |
Set |
Supports decimal entry and enforces the increment. |
|
Currency |
Set |
Formats the value using the unit definition, for example a |
|
Percentage |
Set |
Adds the configured percent suffix. The unit formats the stored number directly. For example, |
|
Data size |
Set |
Read-only rendering scales values through K, M, and G prefixes as appropriate. |
|
Other measurements |
Set |
Uses the configured formatting and stores a number. |
For common element properties, see FSM Mobile Element Properties. For shared validation rules, see FSM Mobile Element Validation Rules.
Number Property Interactions
The following table describes how number properties interact.
|
Property |
Accepted Values |
Default |
Interaction and Behavior |
|---|---|---|---|
|
|
Number. Numeric strings are also coerced during resource normalization. |
|
The numeric value stored by the element. When creating a configuration, use a JSON number literal, such as |
|
|
Number or |
|
Defines inclusive validation limits. |
|
|
Whole number from |
|
When neither unit precision nor |
|
|
Positive number or |
|
The permitted increment used for validation and numeric stepping. When no unit precision applies, a whole number |
|
|
Boolean. |
|
Shows increment and decrement controls that work with |
|
|
String identifier or |
|
Selects a named Number formatting profile from the mobile context's unit collection. A matching profile can set the effective input and display precision and add a prefix or suffix. It doesn't change the stored number or set |
Unit Definitions for Number Elements
unit is a key that identifies a named formatting profile. It is not a separate element type and doesn't convert the stored number. FSM Mobile looks up the configured key in the mobile configuration's "units" collection. If it finds a definition, it uses the definition's formatting members when it renders the Number element.
A unit definition doesn't set the Number element's min, max, step, stepper, or value properties. If the definition includes precision, that precision takes precedence over the element's precision and any precision inferred from step. For scaled values, the read-only display uses at most two decimal places. Precision affects both the editable Number control and display.
The standard routes/mobile.units object supplies these formatting definitions:
{
"routes/mobile": {
"units": {
"usd": { "prefix": "$", "precision": 2 },
"percent": { "suffix": "%" },
"byte": { "suffix": "B", "precision": 0, "multiple": 1024 },
"celsius": { "suffix": "°C" },
"fahrenheit": { "suffix": "°F" }
}
}
}
To add an account-specific unit, add a key to the mobile configuration's "units" collection. Set the Number element's "unit" property to that key. For example:
{
"routes/mobile": {
"units": {
"jpy": { "prefix": "¥", "precision": 0 },
"kilogram": { "suffix": " kg", "precision": 2 }
}
}
}
With these definitions, "unit": "jpy" displays a whole-number amount with a yen prefix. "unit": "kilogram" adds the kg suffix and limits precision to two decimal places without padding trailing zeros. For example, 2.5 can display as 2.5 kg. Unit formatting doesn't change the stored number or convert its measurement.
Unit-definition members are renderer settings rather than Number-element properties. The FSM Mobile renderer reads these members directly. The following table describes the supported unit-definition members.
|
Unit Member |
Configuration Guidance |
Effect |
|---|---|---|
|
|
Use a string. |
Added before the displayed number. |
|
|
Use a string. |
Added after the displayed number. |
|
|
Use a whole number from |
Overrides the element's |
|
|
Use a positive numeric factor greater than |
Scales the read-only display by this factor and adds K, M, or G before the suffix. Scaled values use two decimal places at most. The stored number is unchanged. |
The Celsius suffix is the two-character text °C: Unicode degree sign ° (U+00B0), followed by uppercase C. Use that literal text in JSON. Don't use the HTML entity °C, because unit suffixes are rendered as text rather than decoded as HTML.
Available units depend on the merged configuration. Preserve the standard unit definitions that existing elements use when changing routes/mobile.units.