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 outputThe device is Test Device
- When the
DeviceId
is null will outputThe device is No Device
- When the
DeviceId
is 9999 will outputThe 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 outputUnknown
- When
Temperature.Celsius
is28.3
will output28.3
- When
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 output21.2
- When
{Temperature.Celsius:number(#.##)}
- When
Temperature.Celsius
is 2.123456 will output2.12
- When
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
isMyShipmentId
the output will be{ "ShipmentId": "MyShipmentId"}
- When
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 returnRecord Time: 8/1/25
Record Time: {EntryTime.Utc:date}
will returnRecord 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)}
whenAlert.Trigger.Description
isHello World
will outputHelee Weerld
{Alert.Trigger.Description:replace(Old Company Name,New Company Name)}
whenAlert.Trigger.Description
isAlert for Old Company Name
will outputAlert 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 outputThe alert is closed
whenAlert.IsClosed
is true orThe alert is open
when it is false.{ShipmentId:when(448372,TestShipment}
will outputTestShipment
whenShipmentId
is448372
but will output the shipment ID in all situations.
Updated 1 day ago