Mastering Coda's Formulas
Share
Explore

icon picker
Format

Your formula for individualized text and your best friend in automatic emails
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
Text
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
image.png

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
000
41
I want to eat 41 tacos

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
Win Taco Award
Subject
Taco Award - YOU WON!

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
Name
Amount of Tacos
City
Date
Formatted Email
1
Darth Vader
3
Santa Cruz
6/29/2022
👋 Hey Darth!
CONGRATULATIONS!! - - - You have been randomly selected to win the prestigious TACO AWARD
Since you designated on your input form that you would like 3 tacos delivered on 6/29/2022 we will make sure to get those tacos right to your door.
We have on file that you live in Santa Cruz? Can you confirm this is correct?
Thanks Darth!
Can’t wait to get you your tacos.
2
Yoda
100
San Francisco
8/23/2022
👋 Hey Yoda!
CONGRATULATIONS!! - - - You have been randomly selected to win the prestigious TACO AWARD
Since you designated on your input form that you would like 100 tacos delivered on 8/23/2022 we will make sure to get those tacos right to your door.
We have on file that you live in San Francisco? Can you confirm this is correct?
Thanks Yoda!
Can’t wait to get you your tacos.
3
Luke Skywalker
4
San Jose
9/6/2022
👋 Hey Luke!
CONGRATULATIONS!! - - - You have been randomly selected to win the prestigious TACO AWARD
Since you designated on your input form that you would like 4 tacos delivered on 9/6/2022 we will make sure to get those tacos right to your door.
We have on file that you live in San Jose? Can you confirm this is correct?
Thanks Luke!
Can’t wait to get you your tacos.
There are no rows in this table

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
@Craig Kidd
@Mr. Brian Montoya
There are no people that match the age of 21
There are 3 people that match the age of 22
@Bryan Johnson
@Jackson Fron
@Angie Collier
There are 3 people that match the age of 23
@Megan Smith
@Daniel Ayers
@Coda Man
There are 3 people that match the age of 24
@Ronnie Gross
@Thomas Ward
@Scott Weir
There is 1 people that match the age of 25
@Elizabeth Nguyen
There is 1 people that match the age of 26
@Angela Hill
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
@Matthew Smith

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.