Pendula supports a variety of special syntax options to format merge field values within your templates.
You can use these to display a value in a particular way, or change the contents of the template based upon the value within a merge field.
Using merge field formatting incorrectly can prevent you from saving a template or activating a flow, so ensure you follow this guide carefully and test any templates using advanced formatting thoroughly.
Quick links:
Conditional merge field formatting
Date and Date/Time fields
The default output of a date/time field value from Salesforce will look like this 10 Jan. 2020, 3:04:23 pm
.
To alter the way this value is displayed, you can use three prebuilt formats (long, medium and short) or alternatively by using the customisable date_fmt
formatter.
Please refer to the table below for each format and the output, using the example of a{{ CreatedDate }}
merge field. To replicate the same output with your merge field, simply replaceCreatedDate
with the api name of your intended merge field.
Type | Merge field formatting | Output |
Default (no formatting) | {{ CreatedDate }} |
10 Jan. 2020, 3:04:23 pm |
Long | {{date_long CreatedDate}} |
10 January 2020 at 3:04:23 pm AEST |
Medium | {{date_medium CreatedDate}} |
10 Jan. 2020, 3:04:23 pm |
Short | {{date_short CreatedDate}} |
10/1/20, 3:04 pm |
Custom | {{date_fmt CreatedDate 'yy-MM-dd h:mm:ssa'}} |
20-01-10 3:04:23pm |
Custom | {{date_fmt CreatedDate 'EEEE, d MMMM y'}} |
Monday, 10 January 2020 |
Custom | {{date_fmt CreatedDate "EEEE, d MMMM y 'at' h:mm a" tz='Australia/Sydney'}} |
Wednesday, 10 February 2021 at 5:00 pm |
Timezone override
By default, date/time fields are sent using the timezone and locale specified within the Tenant Settings section of your Pendula settings screen.
You can however, use tz='enter timezone here'
to display date/time values in relation to a different timezone.
An example of when this is useful, is if your default timezone is Sydney, but recipients of your flow are based in Adelaide. In this case, you can use tz='Australia/Adelaide'
to render the date/time value in Adelaide rather than Sydney time.
Timezone overrides can be used in conjunction with the other date/time formatting fields listed above, such as {{date_long CreatedDate tz='Australia/Adelaide'}}
or {{date_fmt CreatedDate "EEEE, d MMMM y 'at' h:mm a" tz='Australia/Adelaide'}}
.
Please refer to the table below for common database time zones.
Region | Merge field formatting |
South Australia | tz='Australia/Adelaide' |
Queensland (most areas) | tz='Australia/Brisbane' |
New South Wales (Yancowinna) | tz='Australia/Broken_Hill' |
Northern Territory | tz='Australia/Darwin' |
Western Australia (Eucla) | tz='Australia/Eucla' |
Tasmania | tz='Australia/Hobart' |
Queensland (Whitsunday Islands) | tz='Australia/Lindeman' |
Lord Howe Island | tz='Australia/Lord_Howe' |
Victoria | tz='Australia/Melbourne' |
Western Australia (most areas) | tz='Australia/Perth' |
New South Wales (most areas) | tz='Australia/Sydney' |
Number and currency fields
Pendula also has special formats available for number and currency fields.
If referencing a currency field in a merge field, please note this does not pull through the $
sign, so you will want to manually add that to the template before the currency field is added.
Please refer to the table below for each format and the output, using the example of a {{ Money }}
merge field with the value of 82.825
.
Type | Merge field formatting | Output |
Default (no formatting) | {{ Money }} |
82.825 |
Decimal (1 min decimal place and 1 max decimal place) | {{num_fmt Money 1 1}} |
82.8 |
Decimal (2 min decimal place and 2 max decimal place) | {{num_fmt Money 2 2}} |
82.83 |
Using merge field formatting in conjunction with a merge field which is null on a record will cause the template to fail to render. Ensure the merge fields you reference with any formatting are either mandatory, or filter out any records which have no value in these fields within the trigger conditions or flow criteria of the flow using theis null
or isnot null
operator.
Conditional merge field formatting
You can use the #if
operator to conditionally display a field based on its availability, in other words, only display a merge field if it actually contains a value.
Please note only one merge field can be referenced within a conditional statement at a time.
Example:
Hey{{#if Name}} {{Name}}{{/if}}, how are you?
If the Name
merge field is null or empty, it will display: Hey, how are you?
If the value of the field is John
, it will display: Hey John, how are you?
You can also set a fallback value with the #else
operator.
Example:
Hey {{#if Name}}{{Name}}{{else}}there{{/if}} What's up?
If the Name
merge field has a value it will display: Hey John! What's up?
However, if the Name
merge field doesn't have a value, it will display: Hey there! What's up?
Consider sending an email where you want feedback from a customer:Please respond back with your answer to {{Company_Email_Address}}
{{#if MobilePhone}}or SMS us at {{Company_Mobile_Number}}{{/if}}
In this example, the second lineor SMS us at {{Company_Mobile_Number}}
will display in the template if there is a value in the MobilePhone field.
You can use #unless
as the inverse of #if
. Its block will be displayed if the field is false
or null
Example:
{{#unless MobilePhone}}Looks like we don't have a number for you!{{/unless}}