Data References in Mobile Form Expressions

Mobile form expressions can reference element properties within their evaluation scope.

Reference

Syntax

Scope and Limitations

Another element

elementName.propertyName

References a property of another element in the current evaluation scope.

Current element

this.propertyName

References the element containing the expression. For example, this.value represents the current element's value.

User resource element

uri.propertyName, such as ppe.options

References an element made available through a Uniform Resource Identifier (URI). The URI must be unique within the FSM Configuration. If an expression references the URI, it must also be a valid JavaScript identifier.

Supported global object

Math.round(…)

Uses a deterministic built-in JavaScript object in an expression that also references an element property.

Form and Table Scope in Mobile Form Expressions

Top-level elements can reference other top-level elements on the same form. A top-level element can't directly reference the values of individual table rows or columns.

The runtime evaluates a table child expression for a specific row. The expression can reference sibling child elements in that row. Use consistent child element names across rows.

Support for referencing a top-level form element from a table child expression depends on the Mobile version. Confirm compatibility before using this reference pattern.

Mobile Form Expression Reference Examples

The following examples demonstrate reference patterns in Mobile form expressions. For scope rules and limitations, see Data References in Mobile Form Expressions.

Referencing Another Element in Mobile Form Expressions

The following expression uses temperature.value to reference another element. The warning CSS class applies when the temperature exceeds 100.

              {
  "temperature": {
    "label": "Temperature",
    "type": "number"
  },
  "temperatureMessage": {
    "label": "Temperature status",
    "type": "html",
    "text": "High temperature",
    "class": "temperature.value > 100 ? 'warning' : ''"
  }
} 

            

Referencing the Current Element in Mobile Form Expressions

The following expression uses this.value to reference the current element:

              {
  "temperature": {
    "label": "Temperature",
    "class": "this.value > 100 ? 'warning' : ''",
    "type": "number"
  }
} 

            

Referencing a Resource Through a URI in Mobile Form Expressions

The following resource supplies PPE options from a custom record search:

              {
  "ppe": {
    "uri": "ppe",
    "type": "datalist",
    "options": {
      "record": "customrecord_ppe",
      "map": {
        "id": "internalid",
        "label": "name"
      }
    }
  }
} 

            

A Job Safety Analysis element can reference the resource through ppe.options.

              {
  "ppe": {
    "uri": "ppe",
    "type": "datalist",
    "options": {
      "record": "customrecord_ppe",
      "map": {
        "id": "internalid",
        "label": "name"
      }
    }
  }
} 

            

Using Supported Global Objects in Mobile Form Expressions

The following expression uses Math.round() with element properties to calculate an average speed:

              {
  "distance": {
    "label": "Distance Traveled (m)",
    "type": "number"
  },
  "time": {
    "label": "Elapsed Time (s)",
    "type": "number"
  },
  "speed": {
    "label": "Average Speed (m/s)",
    "type": "number",
    "value": "Math.round((distance.value || 0) / (time.value || 0))",
    "readonly": true
  }
} 

            

Related Topics

General Notices