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
DeviceIdis 12345 will outputThe device is Test Device - When the
DeviceIdis null will outputThe device is No Device - When the
DeviceIdis 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.Celsiusis null will outputUnknown - When
Temperature.Celsiusis28.3will 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.Celsiusis 21.2000 will output21.2
- When
{Temperature.Celsius:number(#.##)}- When
Temperature.Celsiusis 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
ShipmentIdis null, this will output{ "ShipmentId": null} - When
ShipmentIdisMyShipmentIdthe 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/25Record 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.DescriptionisHello Worldwill outputHelee Weerld{Alert.Trigger.Description:replace(Old Company Name,New Company Name)}whenAlert.Trigger.DescriptionisAlert for Old Company Namewill 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 closedwhenAlert.IsClosedis true orThe alert is openwhen it is false.{ShipmentId:when(448372,TestShipment}will outputTestShipmentwhenShipmentIdis448372but will output the shipment ID in all situations.
Updated about 2 months ago