Expressions are a powerful tool for modifying text and numerical values within Triggers. You can modify:

  1. Table Records: Records you have loaded into the app in a previous statement
  2. App Info: Default app fields, like User, Station, and Time Elapsed on Step
  3. Variables: The value of variables within that run of the app at the time that the Trigger fires.

Common use cases include...

  1. Converting text into a number
  2. Converting a number into text
  3. Modifying the output of a barcode scanner
  4. Combining static text with variable values

If you are planning on using variable values in a text string, you should use the Expression Editor rather than "Static Value" "text".

Accessing the Expression Editor

The Expression Editor is available as an initial choice within "If" statements, and it is available as an option within actions in "Then" statements.

For "If" statements, you can write logic based on an expression.

In "Then" statements, it is available within actions like "Data Manipulation" "Store".

Writing an Expression

To use an expression, you must insert a: 

  • Variable
  • Field from a record 
  • App field
  • Hardcoded value

into the parentheses included in the expression.

In the example below, the value from the variable called "Defect count" is added to a PARSEFLOAT() function.

  • "Data Manipulation" "Store" data: "Expression" "PARSEFLOAT(Variable.Defect count)"

If the expression is valid, you will get a "Valid Expression" message at the bottom of the Editor.

If you plan on using a variable value in a text string, you must use quotes (") to surround the text string, and plus symbols (+) to join the variable value with the string.

Example:

Text: 'My work order ID is: ' + @Table Record.Test WO Record.ID  + 'and my badge ID is: ' + @App Info.Logged-in User.Badge Id

Common Use Cases Explained

Converting Text to a Number

To convert text to a number, you must first decide if you want the number to be a float (with decimal places) or an integer (no decimal places).

Let's imagine that you want to convert text to a float. Here's how you might do that:

  • "Data Manipulation" "Store" data: "Expression" "PARSEFLOAT("123.14")

This will convert "123.14" to 123.14.

Converting Number to Text

Since Tables require a text value for a unique ID, you will need to convert any numbers to text.

To do this, simply add an a set of quotes after the number using the "+" operator.

  • "Data Manipulation" "Store" data: "Expression" 
  • 123.456 + "

Modifying Barcode Scanner Output

First, you must figure out the format of the barcode scanner output. Let's assume that it is text, and you want to convert it to a number.

To do that, you must use PARSEFLOAT() on the scanner output. It looks like this:

  • "Data Manipulation" "Store" data: "Expression" 
  • PARSEFLOAT(Device Output.data)
  • location: "work_order"

Creating a Comma-Separated List of Values

You can combine multiple strings or numbers into one string, with each value separated by a comma. You can add on to an existing field in a table, or simply combine multiple variables or static values.

Here's how to combine the values stored in 2 variables into one text value:

  • "Data Manipulation" "Store" data: "Expression" 
  • Variable.Defect Report-Defect Type + "," + Variable. Defect Report-Defect Description

Further Reading

Did this answer your question?