Merge Tokens and Functions Reference
Merge tokens are the expression syntax used in email template subjects and bodies, and anywhere else the platform merges values into text. Every token takes the form {!...}.
The inner expression must be a dotted path, a $-prefixed system reference, a literal, or a function call. Anything else is not treated as a token.
Token Types
| Token | Resolves to |
|---|
{!Entity.Field} | A field on the record being merged against, for example {!Contact.FirstName}. The first segment is case-sensitive. |
{!$User.*}, {!$CurrentUser.*} | Fields on the user the merge is running for. |
{!$Organization.*} | Fields on the organization. Note there is no $Company token - the organization is exposed as $Organization. |
{!$Label.MyLabel} | A custom label, translated into the current culture. |
{!$Today}, {!$Now} | The current date, and the current date and time. |
{!$Entity.<name>...} | Metadata about an entity in context. |
{!$DataBag.*} | Values supplied by the process running the merge. |
{!$CobrandedUserInfo.*} | Co-branded sender details. |
{!$SystemInfo.*} | System context values. |
{!$True}, {!$False}, {!$Null} | Literal values, for use as function arguments. |
{!"text"} | A string literal. |
{!Function(...)} | A function call. See below. |
Functions
The token picker offers 46 functions in four groups. Argument names below match what the picker inserts.
Logical
| Function | Returns |
|---|
AND(args) | bool |
OR(args) | bool |
Not(value) | bool |
If(expression, trueValue, falseValue) | object |
IsNull(expression) | bool |
IsBlank(expression) | bool |
HasValue(expression) | bool |
NullValue(expression, substitute) | object |
Equal(value1, value2) | bool |
NotEqual(value1, value2) | bool |
LessThan(value1, value2) | bool |
LessThanOrEqual(value1, value2) | bool |
MoreThan(value1, value2) | bool |
MoreThanOrEqual(value1, value2) | bool |
Text
| Function | Returns |
|---|
Text(expression) | string |
Concat(args) | string |
Len(str) | int |
ToLower(item) | string |
ToUpper(item) | string |
Contains(str, value) | bool |
StartsWith(str, value) | bool |
Replace(str, pattern, value, ignoreCase) | string |
FormatNumber(value, decimalPlaces) | string |
FormatCurrency(value, currencyCode, decimalPlaces) | string |
FormatDate(dateTime) | string |
FormatDateTime(dateTime) | string |
FormatAddress(street, city, state, postalCode, country) | string |
EscapeSingleQuote(value) | string |
UrlEncode(value) | string |
UrlDecode(value) | string |
Date and Time
| Function | Returns |
|---|
Today() | string |
AddDays(date, days) | DateTime |
AddDateTimePart(dateTime, part, value) | DateTime |
ToUserTime(dateTime) | DateTime |
AddDateTimePart accepts a part of day, hour, minute, second, month, year or tick, singular or plural.
Advanced
| Function | Returns |
|---|
Add(args) | decimal |
IsInRole(role) | bool |
NewGuid() | string |
GetAppName() | string |
GetSiteUrl() | string |
PageUrl() | string |
UrlFor(action, controller, routeValues) | string |
UrlForAsset(relativePath) | string |
ActivePageUrl(name, routeValues) | string |
UrlParam(name) | string |
UrlTokenEncode(value) | string |
Encrypt(value, base64Encoding) | string |
Three branding helpers are not offered by default.GetButtonStyle, GetDefaultButtonStyle and GetLogoUrl exist but are gated and do not appear in the standard picker.
Validating a Token
The token picker includes a Validate Syntax action, which checks the expression and reports undefined fields before you insert it. Use it - the send path does no schema validation.
Behavior Worth Knowing
- Field names are case-sensitive. A token whose first path segment differs in case will not resolve.
- Unresolved tokens are removed from outgoing email. A token that cannot be resolved is stripped rather than delivered as literal text, so a typo produces a silent gap. Preview before shipping. This stripping is specific to the email path; other merge consumers leave unresolved tokens in place.
- Encoding is contextual. Substituted values are HTML-encoded for HTML bodies, except where the source field is rich text, which passes through raw. Subjects are never HTML-encoded.
- Tokens are HTML-decoded before matching, so tokens that a WYSIWYG editor has encoded still resolve.
- Custom labels and picklist labels honor the current culture, which is how a single template renders in each recipient's language. This depends on the organization having active languages configured - see Email Template Localization at Send Time.
See More
<< Email Template Localization at Send Time