Gallery
Kuovonne's Guide to Airtable
Share
Explore
Kuovonne's Guide to Airtable
Templates

Templates using field values

Thank Kuovonne for creating this content!
People often want to merge field values with templates to send in automated email messages.
For example, you may want to automated an email like this:
Dear {Customer Name},

Your reservation for {Service} on {Date} with {Provider} has been confirmed.

We look forward to seeing you then.

Template in the Email Action

When sending an email message using a native Airtable automation, you set up the template for the message within the email action itself.
Pros:
This is usually the easiest system to configure. You can see the template in the context of the automation itself.
If you change the name of a field, Airtable automatically updates the template to the new field name. The automation shows up in the built in “Show Dependencies” for each field used in the template.
You do not need any formulas or scripts.
Cons:
It is difficult to view and compare multiple templates at the same time.
The template itself cannot have variations, such as including additional content under special circumstances.
Each template requires its own email action.
Only people with creator permissions can create and modify templates.

Template with CONCATENATE() formula

Some people build the body of the email message using a long CONCATENATE() formula field, and then include only the formula field itself as the message in the email action.The formula itself is the template.
CONCATENATE(
"Dear " & {Customer Name} & ",\n",
"\n",
"Your reservation for " & {Service},
" on " & DATETIME_FORMAT({Date}, "MM/DD/YYYY"),
" with " & {Provider} & " has been confirmed.\n"
"\n",
"We look forward to seeing you then."
)
Pros:
If you change the name of a field, Airtable automatically updates the formula to the new field name. All fields involved show up in the built in “Show Dependencies” system.
You can include complex variations in the formula, such as including or excluding text for special situations. A single formula field can take the place of multiple templates.
Cons:
It is difficult to view and compare multiple templates at the same time.
Editing the formula template takes place away from the configuration of the automation that sends the template.
Crafting the formula text to get the correct formatting, spacing, punctuation, etc. can be tricky.
Only people with creator permissions can create and modify the template formula.

Linked Template Table w/ SUBSTITUTE() formula

An extension of the formula method is to use a linked template table in conjunction with a formula. The template table has a long text field with the template. You link your main record to the template you want, then use a rollup of the long text field combined with a formula with lots of SUBSTITUTE() functions to replace template text with field values.
minus
This is my least-used method because it fractures the logic across the most places.

SUBSTUTE(SUBSTUTE(SUBSTUTE(SUBSTUTE(
ARRAYJOIN(values),
"{Customer Name}", {Customer Name}),
"{Service}", {Service}),
"{Date}", DATETIME_FORMAT({Date}, "MM/DD/YYYY")),
"{Provider}", {Provider})
Pros:
You can store multiple templates in a single table, making it easier to maintain and update different templates.
People do not need creator access to edit templates.
Cons:
You must hard-code the field names in BOTH the template text and the SUBSTITUTE() formula. Changing field names will break the template. The dependencies will not appear in the built in “Show Dependencies” system.
The template itself cannot have variations, such as including additional content under special circumstances. (Although you can include additional variations with more complicated formulas.)

Template with a Script

Another option is to use a table of templates with a script that does the merging for you. This is what my and do. Note that in my system field names need to be surrounded by {{double curly braces}} or {{{triple curly braces}}} versus {single curly braces}.
Pros:
You can store multiple templates in a single table, making it easier to maintain and update different templates.
People do not need creator access to edit templates.
You can include complex variations in the template, based on what the script supports. For example, my system uses Mustache syntax which lets you including or excluding text for special situations.
You do not need to use formulas.
Cons:
You must hard-code the field names in the template text. Changing field names will break the template. The dependencies will not appear in the built in “Show Dependencies” system.
Depending on the script, there may be some limitations on field names. For example, my system does not work for field names with special characters such as periods.
You might need workarounds for formatting dates and numbers.

A combination of methods

You can combine techniques from multiple methods. For example, you could have an email where most of the message is calculated in a formula field, but a standard opening/closing are in the email action template.
Note however that this spits up the logic in multiple places which can make the system more difficult to maintain.
Thank Kuovonne for creating this content!

Share
 
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.