Configuring FSM Mobile Number Elements

Note:

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

"precision": 0, "step": 1, optionally "stepper": true. Set min and max where the range is known.

Limits entry and display to whole numbers.

Decimal measurements

Set step to the smallest permitted increment, such as 0.25. Unless a unit defines precision, the decimal places in step determine the displayed decimal places.

Supports decimal entry and enforces the increment.

Currency

Set unit to a configured currency unit, such as usd. Use the unit definition's prefix or suffix and precision, commonly 2. Use a matching step, commonly 0.01.

Formats the value using the unit definition, for example a $ prefix and up to two decimal places.

Percentage

Set unit to a configured percentage unit, such as percent. Use precision and step appropriate for the accepted percentage value.

Adds the configured percent suffix. The unit formats the stored number directly. For example, 0.8554 is not automatically converted to 85.54%. Configure the appropriate field mapping when NetSuite stores a fraction.

Data size

Set unit to a unit definition with multiple, for example byte with "multiple": 1024, a B suffix, and precision 0.

Read-only rendering scales values through K, M, and G prefixes as appropriate.

Other measurements

Set unit to another configured unit identifier, such as a temperature unit, and define its suffix, prefix, and precision.

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

value

Number. Numeric strings are also coerced during resource normalization.

null

The numeric value stored by the element. When creating a configuration, use a JSON number literal, such as 1.25, rather than a numeric string such as "1.25".

min / max

Number or null.

null

Defines inclusive validation limits.

precision

Whole number from 0 through 8.

8

When neither unit precision nor step display precision applies, precision limits the number of decimal places for entry and display in FSM Mobile. 0 prevents decimal entry. It doesn't add a stored-value validation rule. A unit precision takes precedence.

step

Positive number or null.

null

The permitted increment used for validation and numeric stepping. When no unit precision applies, a whole number step displays zero decimal places and a fractional step displays its number of decimal places. Use 1 for whole numbers, 0.01 for cents, and 0.25 for quarter-unit increments.

stepper

Boolean.

false

Shows increment and decrement controls that work with step. Setting stepper to true alone doesn't change numeric validation.

unit

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 min, max, step, stepper, or value. An unrecognized identifier displays the number without unit formatting.

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

prefix

Use a string.

Added before the displayed number.

suffix

Use a string.

Added after the displayed number.

precision

Use a whole number from 0 through 8, consistent with the Number element's precision property.

Overrides the element's precision and step-derived precision for the editable control and display.

multiple

Use a positive numeric factor greater than 1, such as 1024 for bytes.

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.

Additional Information

Related Topics

General Notices