Select Page
Google Docs Function - Template Guide
Google Docs Function - Template Guide

Google Docs Function - Template Guide

The Google Docs Template Guide is used to setup the Google Docs Function. The Google Docs Function allows you to automatically create documents inside Google Docs using your Airtable data. You can generate single page and multi-page documents that display a single record or list of records from your Airtable base. It will also automatically upload the newly created PDF file back into your Airtable base in an Attachment file and the Google Doc URL into a URL or Text field. Use Cases: Invoices, Quotes, Contracts, Form Entries, Reports, and more

image

For even more advanced documents, you can set up multiple document templates based on conditionals from your Airtable data and you can use the custom formatting templates inside your document for Tables, Text, Numbers, Dates, Images, Links, and Grids.

Features:

  • - Automatically generate documents with your Airtable data
  • - Create single or multi-page documents
  • - Bulk create documents for multiple Airtable records or create documents per single record
  • - Save as a PDF back to an Attachment field in your Airtable base
  • - Save the Google Doc URL back to a URL or Text field in your Airtable base
  • - Tables in your document automatically created to match the number of records needed
  • - Add advanced formatting with specific in-document templates for tables, images, links, content, and grids.

In this article

Pre-Made Google Docs Templates

To help you get started, copy one of our Google Docs pre-made templates. You can replace the placeholders with your field and table names, then customize the document to fit your needs.

Document Formatting Templates

Field Placeholder - Basic Document Setup and Single Page Documents

The Field Placeholder is the basic way to create your document. You can use the Field Placeholder when you need to add Airtable data from a single record per document.

{{Your Airtable Field Name}} - This is the placeholder you’ll use in your document template. These are used to insert your data anywhere in the file. Wrap your Airtable field name in curly brackets - {{Your Airtable Field Name}}

Example: You have an Invoices table in your Airtable base where you want to generate invoice documents from. You have a Linked Record field to the Companies table with the Company Name field and you have Lookup fields for the Address and Email.

In your Google Docs template file, you would add them as {{Company Name}}, {{Address}}, and {{Email}} where you want them to appear when the document is generated. In this instance, you also have a Single-Select field called Services Title where you added a single service, you use the {{Services Title}} placeholder.

(To add a list of multiple services and invoice line items on your Invoices, see the Table instructions below)

image

Table - Multiple Records on 1 Document and Multi-Page Documents

Useful for multiple records on one document and for multi-page documents

You can create a table in Google Docs that is dynamically generated based on the exact size you need to fit your Airtable data. This is useful when you have multiple Airtable records that need to be added to a single document, like an invoice with multiple line items, a quote, or a report.

You can also send data into a document from multiple Airtable tables!

Google Doc Template with Table template

Merged Document with Airtable Data

image
image

In the Quote example above, we’re bringing in Airtable data from 2 different tables - the Quotes table and the Budget Items table. The Quotes table links to the Budget Items table. We’ve added multiple Budget Items to the Quote for the ‘Sunlight Acoustics’ company.

Add the Google Docs Quote Template to your Google Workspace to see how it’s set up

You can add the Project Budget Airtable demo base to your workspace to see how it’s set up.

Quotes Table

image

Budget Items Table

image

The setup in On2Air uses the Quotes table as the main table to add {{My Field Name Placeholders}} and then uses the {{table source}} template to bring in data from the Budget Items table.

Tables in your document can be created with data from your Airtable record(s) in a few different ways:

  • Linked Record Field (common use case for multiple records) - Use a Linked Record field (to another Airtable Table), along with field names of the linked record table.
    • This is useful for generating documents where you want to include a list of multiple records as a list in a single document, such as on an Invoice or a Quote
    • Format: {{table source="Linked Table Name (from Linked Record)" field="Field Name in Linked Table"}}
    • How You Can Set It Up
      1. Copy our Project Demo Airtable base - It has a Quotes table with a Linked record field to the Budget Items table. The Budget Items are a list of items you need on a Quote. The Quotes table is what you use to set up the On2Air document automation and the Budget Items will be added to your document.
      2. Use our Quote Template Google Docs file or add the following table template syntax to a Google Docs file

      {{table header=“Item|Hourly Rate|Units Price|Fixed Cost|Category” source=“Budget Items" fields="Item Name|Hours*Rate|Units*Price|Fixed Cost|Category"}}

      • table header - labels the headers in the first row of the table
      • source - Budget Items is the secondary table from a Linked record field in the Quotes table
      • fields - field names from the Budget Items table
      • In the Budget Items table in the Airtable base, there are fields for Item Name (Single text), Hours*Rate (formula), Units*Price (formula), Fixed Cost (Currency), and Category (Single Select)

      • Quotes is the main table in the On2Air function setup
      image
      1. In the Quotes table, create a single record and add multiple records from the Budget Items table in your Budget Items linked record field
      2. Set up your On2Air function as described here
      3. Click the checkbox to Process Quote
      image

  • Lookup/Rollup Field Values - Use source with Lookup/Rollup values to display in table For multiple columns, list these in separate cells next to each other:
    • ex: {{table source="Lookup Field 1"}} | {{table source="Lookup Field 2"}} note: For rollup values, the formula should be: ARRAYJOIN(values,"|")

  • MultiSelect Field Values - Create a list of the values from a multiselect selection ex: {{table source="MultiSelect Field"}} - Should be used alone and not combined with other source values Note: This will be a single column table

Table Syntax

{{table source=" | "}} {{/table}} - Insert your field names for each column of the table

{{#table source}} - Your table name in Airtable

Example:

Simple: {{table source="Template Names|Template Ages”}}

Complex: {{#table source="Table Data" borders="sides: none" columnWidths="0.7,3,,,1"}}

Options:

source - Field Name of the Data Source(s).

Supports following field types: MultiSelect, Lookup, Rollup, Linked Record

Field Type Details:

Linked Record - For Linked Record Fields, enter the linked record field in the source parameter, then use a fields parameter either in the table template or an inner body template

fields - Only use with a Record Link Field, set to use the fields within a linked table. Separate fields with | character by default ex: {{table source="Linked Field" fields="Name|Status|Attachments"}}

MultiSelect - Should be used alone and not combined with other source values

Lookup - Can use multiple Lookup fields (separated by the | character by default) - must be lookups on the same table and not use any conditional selection to avoid misplaced values

Rollup - For rollups, use an ARRAYJOIN function and pass the | character as 2nd parameter to separate values. ex: ARRAYJOIN(values, "|")

header - shortcut to add headers to the table. ex: {{table header=”Column A|Column B|Column C”}}

borders - borders are on by default.

To remove borders: {{table borders="sides: none"}} To have top/bottom borders only: {{table borders="sides:top,bottom; color:#FFFFFF; width:0.5; dashStyle:solid"}} To set dashed borders on all: {{table borders="sides:all; color:#FFFFFF; width:0.5; dashStyle:dash"}}

columnWidths - set your column widths in inches

ex: {{table columnWidths="0.5,1,1"}} Note: to allow a column to use remaining, leave blank. Ex: {{table columnWidths="1,,1"}} will set 1st and 3rd columns to 1 inch, and 2nd will use remaining

sort - sort the table data prior to display.

ex: {{table sort="field: Name; order:asc"}}field - the field name to use for sorting purposes order - (asc|desc) Either ascending (asc) or descending (desc)

separator - set to a value to use for determining how source and fields parameters are separated ex: {{table source="Field A,Field B" separator=","}}

weightedFontFamily - change the font and weight of font of the text

Example: {{table weightedFontFamily=”fontFamily: ZCOOL KuaiLe; weight: 600”}}

fontFamily - Select from available Google Fonts

weight - Value between 100 and 900 to determine the weight (i.e. thickness) of the font. 400 is default

fontSize - the size of the font, in inches

ex: {{table fontSize="14"}}

grouping - group records from Multi-select or Linked record fields

{{table .....table config.... grouping="GroupFieldName"}}
Your Airtable base with a select field
Your Airtable base with a select field

Document with records grouped
Document with records grouped

spread - spread out groupings from your grouped Multi-select or Linked Record field

If using a Multiselect field or a Linked Record Field with Multiple Records enabled, you can "spread" out the groupings to each individual item. Instead of how Airtable does groupings where it will group multi-select items only if they have all the exact same items, this will group on the individual items - which means records will show up in multiple tables if has multiple items of the group field.

Example:

{{table .....table config.... grouping="field: GroupFieldName; style:[bold=1|fontSize=22]; label: GroupLabelField; sort: GroupSortField; order: desc; separator: \n\n; sep_style:[]; spread: 1"}}

Advanced Table Usage

(Documentation is a work in Progress for Advanced - contact support if looking to do more advanced table use case)

{{#body}}{{/body}} - Determines the display inside the table cells

Example: {{#body evenColor=”#FFFFFF” oddColor=”#0A0A0A” oddFgColor=”#FFFFFF”}} {{cell field=”Name”}} {{cell field=”Image” type=”image” index=”first” size=”width: 3”}} {{cell field=”Notes”}} {{cell field=”Url” type=”link” labelField=”Name”}} {{#cell type=”text”}} {{text value=”Name: ”}}{{text field=”Name”}}{{text value=”\\n”}} {{text value=”Notes: ”}}{{text field=”Notes”}}{{text value=”\\n”}} {{/cell}} {{/body}}

Options:

evenColor - use HTML Hex color codes

oddColor - use HTML Hex color codes

oddFgColor - Foreground color of each odd row - use HTML Hex color codes

evenFgColor - Foreground color of each even row - use HTML Hex color codes

{{cell field="Your Airtable Field Name"}} - Used to determine which field in Airtable is used

Example: {{cell field=”Notes”}} OR {{cell field=”Image” type=”image” index=”first” size=”width: 3”}}

Options:

labelField - add a name for the link (instead of displaying the entire URL) foregroundColor - use HTML Hex color codes

{{#cell type}} - you can use text, image, and link

Text Options:

{{text value="static text"}} - any static text value you want to use in your table. This value never changes. You can also use formatting such as \\n to create separate lines.

{{text field="Your Airtable field name"}} - what you want displayed in the table field. Typically, this will be Your Airtable Field Name

Example:


{{#table source="Table Data” borders=”sides: none” columnWidths="0.7,3,,,1”}}

{{#body evenColor=”#FFFFFF” oddColor=”#0A0A0A” oddFgColor=”#FFFFFF”}}
    {{cell field=”Name”}}
    {{cell field=”Image” type=”image” index=”first” size=”width: 3”}}
    {{cell field=”Notes”}}
    {{cell field=”Url” type=”link” labelField=”Name”}}
    {{#cell type=”text”}}
	{{text value=”Name: ”}}{{text field=”Name”}}{{text value=”\\n”}}
        {{text value=”Notes: ”}}{{text field=”Notes”}}{{text value=”\\n”}}
    {{/cell}}
{{/body}}

{{/table}}```

Image

Insert images in a specific location in your document

There are 2 ways to insert images - with a Placeholder or with the {{Image field}} parameter

To use images with a Placeholder:

  • Create a basic placeholder image
  • Insert your placeholder image into your document
  • Right-click your image and choose Alt Text
  • In the Title field, add the name of your Airtable Field Name surrounded by brackets Example: {{My Airtable Field Name}}

To use images with the {{image field}} parameter:

  • Use {{image field=" "}}
  • Add your Airtable field name in the parentheses

Options:

index - determines which order the image will be pulled from. Use first, random, last, or the specific index value (the first will be index 0)

size - use height and/or width and then specify in inches. If only one is set, the other dimension will be determined by the original image dimensions ratio ex: {{image size="width: 6.5; height: 4"}}

url - will make the image a link to the specified URL

Examples:{{image field="Attachments" index="random" size="width: 5"}} - select a random attachment and fix width to 5 inches {{image field="Attachments" index="first" url="{{URL}}"}} - select first attachment item and make it a link to the value in the URL field

Link

This is used to insert your Airtable data as a link inside your document

{{link field="Your Airtable Field Name"}} - the name of the Airtable field that contains what you want to link

{{link url=" "}} - the url for what you want to link

Options:

labelField - add a name for the link (instead of displaying the entire URL)

foregroundColor - use HTML Hex color codes

Content

Paragraph

{{#p}} {{/p}} - Creates a paragraph

Options: shading -

__

Heading

{{#heading level="title"}} {{/heading}} - Creates Headings

level - The heading level. Valid options: title|subtitle|1|2|3|4|5|6 __

Number

{{number}}

Number field - Format data as a number

Options:

format - determines your number format - example - 0.00. View available format options

field - your Airtable field name

__

Date

{{date}}

Date field - Format data as a date

Options:

format- use date formatting (i.e. YYYY-DD-MM).

field - your Airtable field name

Grid

Adds all data from a field, linked table and will generate a grid table where everything is added. Most parameters from Tables are valid here. View Table documentation for styling parameters

{{#grid}} {{/grid}}

Options:

type - The grid cell type. Available options: text|image|link|number|date width - The width of each grid cell columns - you specify how many columns to be used in the grid

Default: 3 columns

Example:

{{#grid source="Logo” type="image” size="width: 1.5” columns="2" max="10" sort="Name"}}
{{/grid}}

Advanced Grid

Conditional Formatting

ifEq - only display when the data from this field is equal to a certain value. This parameter needs to be your Field Name in Airtable.

ifVal - only display if this value is present. This parameter needs to be a specific Value from the Field Name you chose.

Example: {{link field=”Record Link” foregroundColor=”#FF0000” ifEq=”Name” ifVal=”Client A”}}

More Examples

These examples shows some ways to use the templates in your Docs


{{#table source="Table Data” borders="sides: none" columnWidths="0.7,3,,,1”}}

{{#body evenColor="#FFFFFF” oddColor=”#0A0A0A” oddFgColor="#FFFFFF”}}
    {{cell field="Name”}}
    {{cell field="Image” type="image” index="first” size="width: 3”}}
    {{cell field="Notes”}}
    {{cell field="Url” type="link” labelField="Name”}}
    {{#cell type="text”}}
	{{text value="Name: ”}}{{text field="Name”}}{{text value="\\n”}}
            {{text value="Notes: ”}}{{text field="Notes”}}{{text value="\\n”}}
    {{/cell}}
{{/body}}

{{/table}}

{{link field="Record Link” foregroundColor="#FF0000” ifEq="Name” ifVal="Client A”}}

{{#p shading="backgroundColor: #FF0000”}}
This is the last paragraph for {{Name}}
{{/p}}

{{#heading level="title"}}My First Title{{/heading}}

{{number field="Number” format="0.00”}}
{{date field="Date” format="YYYY-DD-MM”}}

{{#grid source="Template Names”}}
{{/grid}}

{{image field="Logo” index="random” size="width: 6.5”}}

{{#grid source="Logo” type=”image” size="width: 1.5”}}
{{/grid}}

My Name is: {{Name}}```

image

Advanced

For Advanced Users. View possible parameter options for the following: