Skip to main content
Using merge dates in an email template

How to format date fields for an email template.

Updated over a week ago

When using merge fields in an email template, you may want to format the date and time. In the below example, the date is formatted with the time, however, you may wish to format this date differently.

Perhaps you wish to remove the time, or show the day of the week. Unfortunately, you can't specify a format for a merge field.

In this customization example, we will format the date field first, and then display this formatted date instead of the merged date field.

This will require you to:

In the below example, we will format the Due Date of an invoice notification, so that it will display the date without the time.

Note: This article assumes you are strong with the basics of customization.


Identify the merge date fields

In order to format the date fields in an email template, you will need to find the merge field you wish to overwrite. This example will use the Invoice Notification email template.

1. On the Send Email app, select Edit Templates.

2. Search for and select the email template you wish to edit. In this example, we will edit the Invoice Notification template.

3. In the email body, find the merge date field you wish to format. Copy and paste the entire field to make sure you have the exact spelling. Also make sure you include the table name. In the below example, the field name we are copying is Invoice.DueDate.

You aren't changing anything in this template, so you don't need to save it.


Customize the screen which uses the email template

1. Navigate to the screen which uses the email template, and customize it. In the below example, we will edit the New / Edit Invoice screen. (You may need to make a copy of the screen.)

2. You will need to find the control which sends the email and go to its Click event. In the below example, the Email button is the control which uses the email template, so we go into its Click event.

3. The next part is tricky. Merging fields is done with the Character Functions action. You will need to find these character function actions which merge the table information with the email body.

It is important to know what action result name is used to hold the body text of the email. Remember this action result name.

In the below example for sending an invoice notification, there are four Character Functions actions which merge using the action result resultEmailBodyMerge.


Format the date

Before you format this date, you will need two things:

  • The name of the merge field that holds the date

  • The name of the action result that holds the email body

Also, you will need to insert actions before the character function gets a chance to do its merge fields action.

1. Before the character functions merge fields on the email body, insert Date Functions action.

2. Using this function, format the date as you want and create a new action result for it. In the below example, we are formatting the DueDate field of the invoice, which is a control found on the screen. We format this date and store the result in resultDueDate. Make sure you add an internal note to indicate what you are doing.

3. Time for a new action. Immediately below your Date Functions, add a new Character Functions action. Again, this is before all the character functions that merge the fields of the email body.

4. For this action:

  • Select a function: Replace

  • Within text: use the action result holding the email body text (Step 3 of Customize the screen which uses the email template section.)

  • Replace this: use the merge field as found in the email template (Step 3 of Identify Merge Fields section).

  • With this: use the action result from above in step 2

  • Store result in: same action result from Within text.

5. Give this action a proper Internal Comment. In the action list, it will look like this:

6. Close the action list, and then close the screen.

And now, when we send the email, we can see a preview and the Due Date is now formatted how I wanted it:

Of course, you would need to do the same to the Invoice date, but it would follow the same steps.

Did this answer your question?