Nothing is as delightful as sending off 100’s of automatic emails with the push of a button all individualized per recipient. Thanks to format() we can do that!
Before everything - What is this formula?
format() allows you to take blocks of text and input individualized information into that block. Try it! Type in any word in the box below and watch the text update
Hey Anonymous, you wrote:
First - let’s just learn how it works.
The format() formula is like saying:
Hey Coda, Im going to give you some text, maybe a sentence or a paragraph. But I also want you to input unique information within the text like names, numbers, or dates? Can you do that? format() is a formula that takes the following arguments:
TEMPLATE
The template is the body of text you want to input information into. It can be as simple as a sentence, or as complex as an email with colored formatting, hyperlinks, lists, etc.
The template also must include bracketed numbers in each place you want to input information.
This is a bracketed number: {1} TEXT
The text is the unique information you want to INPUT into your format() formula. The bracketed numbers inside your template are the spots where your text will be placed.
The text arguments are variable - meaning you can have just 1 argument {1} or as many as you like!
Take this formula for example: My name is Anonymous User and I am 30 years old
This is how its broken down.
The template is a general statement about someones age with two brackets. The first bracket in my template {1} was autofilled with user().name while the second bracket {2} was filled with my second text argument of 30
Second - Best practice with Format()
format() can be used for short text or for long text. There is a different best practice for each
Short Text
When you are using format() for short text, just store the template itself within the formula. Heres an example:
Adjust the slider below to change your short text
Long Text
Using format() in long-text is where the formula really starts to supercharge your docs. When you use format() in long-text situations, best practice is to store the text inside of a table that you can reference.
The best practical example is storing text for sending automatic emails. Lets look at a thorough example
Using format() for emails
Let’s take a fictitious example where you are running a campaign where individuals are chosen to win the prestigious TACO AWARD. Once they win the award - you obviously want to send them a personalized email based off the data they submitted in a form.
format() will let us do that, and we are going to store the template inside another table
In order to do this you are going to have a template table, and then you are going to actually format() the email within the Responses table
Template Table
Click into the card to see the template with the {1} arguments
Responses table
This is the fictitious responses table that holds the information that will populate your template. Pay special attention to the Formatted Email column below in yellow. Click in to view its formula to see how the template is populated
Some final tips and things to try:
the lineBreak() formula is a really powerful formula to use within format() Within the text arguments itself, you can use if() or concatenate() to to conditionally change your templates Check out how I used the format() function below (originally on the walkthrough) There are 2 people that match the age of 20 There are no people that match the age of 21 There are 3 people that match the age of 22 There are 3 people that match the age of 23 There are 3 people that match the age of 24 There is 1 people that match the age of 25 There is 1 people that match the age of 26 There are no people that match the age of 27 There are no people that match the age of 28 There is 1 people that match the age of 29