Template Formatters

Formatters allow you to tweak the values which appear in your template. They're used by adding a colon (":") after the variable name within the curly braces.

For example, the template This record is from {EntryTime.Utc:date(M/d/yy)} would output something like This record is from 7/5/25 (depending on the value of EntryTime.Utc).

The colon separates the variable name (EntryTime.Utc) from the format (date(M/d/yy)). More information on each formatter like what it does and how to use it can be found below.

Multiple Formatters

Formatters can be "chained" which allows you to apply multiple formatters to a variable applied in order by using the vertical bar character "|".

For example this template: The device is {DeviceId:when(12345,Test Device)|default(No Device)}

  • When DeviceId is 12345 will output The device is Test Device
  • When the DeviceId is null will output The device is No Device
  • When the DeviceId is 9999 will output The device is 9999

Formatters

default(defaultValue)

Will output defaultValue when the variable is null or empty, otherwise it returns variable.

Examples:

  • {Temperature.Celsius:default(Unknown)}
    • When Temperature.Celsius is null will output Unknown
    • When Temperature.Celsius is 28.3 will output 28.3

number(numberPattern) or number

Format the variable as a number. If variable is null then null will be returned. If the variable is not a number the value INVALID_NUMBER will be returned. numberPattern uses the same format pattern described here. If this formatter is called without the numberPattern the default number format will be used.

Examples:

  • {Temperature.Celsius:number}
    • When Temperature.Celsius is 21.2000 will output 21.2
  • {Temperature.Celsius:number(#.##)}
    • When Temperature.Celsius is 2.123456 will output 2.12

jsonString

If variable is null this returns null, otherwise it returns the value wrapped in quotation marks. Useful for building templates that output JSON.

Examples

  • { "ShipmentId": {ShipmentId:jsonString}}
    • When ShipmentId is null, this will output { "ShipmentId": null}
    • When ShipmentId is MyShipmentId the output will be { "ShipmentId": "MyShipmentId"}

date(datePattern) or date

Format the variable as a date. If variable is null then null will be returned. If input value is not a date or unix epoch time then the value INVALID_DATE will be returned. datePattern follows the format pattern described here. If date is called without a pattern the ISO 8601 pattern will be used: yyyy-MM-ddTHH:mm.ssZ.

Examples:

When EntryTime.Utc is 2025-08-01 8:36pm +0

  • Record Time: {EntryTime.Utc:date(M/d/yy)} will return Record Time: 8/1/25
  • Record Time: {EntryTime.Utc:date}will return Record Time: 2025-08-01T20:36:00Z

replace(oldValue,newValue)

Replaces any occurrences of oldValue with newValue in the value of the variable. Useful for escaping quotation marks when building JSON. Commas can be used in oldValue or newValue by using a backslash like \,. The replace is case-sensitive and whitespace around the values is preserved.

Examples:

  • {Alert.Trigger.Description:replace(o,ee)} when Alert.Trigger.Description is Hello World will output Helee Weerld
  • {Alert.Trigger.Description:replace(Old Company Name,New Company Name)} when Alert.Trigger.Description is Alert for Old Company Name will output Alert for New Company Name

when(valueToCompare,valueIfMatch,valueIfNotMatch) or when(valueToCompare,valueIfMatch)

Allows for a specified value to be returned if the variable matches an expected value (case-sensitive). When the variable matches valueToCompare then valueIfMatch will be returned. When it doesn't match valueIfNotMatch will be returned if it was specified. If no valueIfNotMatch was provided, then the original variable value will be returned.

Examples:

  • The alert is {Alert.IsClosed:when(true,closed,open)} will output The alert is closedwhen Alert.IsClosed is true or The alert is open when it is false.
  • {ShipmentId:when(448372,TestShipment} will output TestShipment when ShipmentId is 448372but will output the shipment ID in all situations.