Maven Documents Template Builder is an add-on that you can install on a Google Docs, Google Sheets, DOCX, or XLSX file and use it to build a template document with the data you have on Salesforce.
Go to workspace.google.com/marketplace/app/maven_documents/430563853893 and click Install.
Click Continue in the appeared message.
In the opened window, select the Google account you want to use.
Check out the listed permissions by clicking the "(i)" icon and then clicking Allow.
Read the information message and click Done.
After you follow these steps, you can now create your template using Google Sheets and use the "Template Builder" add-on.
Building the template begins with running Template Builder on Google Sheets.
Open the Google Sheets that you've added to Document Template in Maven Documents and click on the "Extensions" tab.
Hover over the "Maven Documents" item in the dropdown list and click on Template Builder.
You'll find the "Template Builder" work pane on the right side of the Google Sheets. The Object and Fields from the query that you built in Query Builder are reflected in Template Builder.
Before you start building the template, let's have a glance at what we call the Template Builder work pane.
The "{} Fields" tab.
Here you will find the objects and the fields you added to the query in Document Solution. All objects and fields can be inserted into the document with one click.
The "</>Elements" tab.
Here you have a picklist with the elements that could be inserted and used in the document. For detailed information on every element, you can check the "Google Sheets Elements" reference page.
The "fx" or "Expression Builder" tab.
Expression Builder lets you create expressions (similar to formula fields in Salesforce) without needing a formula field directly on your document. More on how Expression Builder operates can be found in the corresponding sub-section. You can also read more about expressions and their syntax on the "Expressions" page.
The "Refresh Nodes" button.
This button serves two purposes:
In Google Sheets, you can build your templates using everything that they have to offer. However, Maven Documents allows you to put Salesforce data in the document, and that's what Template Builder is used for.
After successfully adding the document ID to the Document Template in Maven Documents, the "Fields" section in Template Builder now shows all the fields from the root queries that you created in the previous section. The "OpportunityLineItems" query's fields are not available yet, because their availability depends on the context.
If the fields are not showing, click the "Refresh" button.
Now, all you need to do is click on the field you want and it will be added to the document. The fields from Template Builder are added in the "{!QueryName.FieldName}" notation. You can use that notation to add fields manually but in most cases, Template Builder is the easier option.
Now it's time to add some fields to the quote document. In our example, we are using the cell in the second row and the "B" column, and further examples will consider that location. But you can start with whatever cell you like.
Let's see how you can add the fields:
Pretty simple, right? All the fields you've put using Template Builder or manually in the "{!QueryName.FieldName}" notation are dynamic. It means they depend on the results that the query returned.
Everything you have done up to this point has been the same as creating a document using Google Docs. Now you are going to showcase some elements (and element attributes) that are specific to Google Sheets.
In Google Docs, you use the "Table" element to show information about the products from the "OpportunityLineItems" sub-query. In Sheets, you use the "Repeater" element instead. In Google Sheets, you can use two types of Repeater:
Let's use the vertical repeater to show the information about the Opportunities products from the "OpportunityLineItems" sub-query.
Select a cell where you want your products to be shown. Then, in Template Builder open the "Elements" tab.
Select the "Repeater" element. Repeater iterates through records selected in the "Value" parameter. The "Variable" parameter represents the current record in the iteration.
Referencing variables inside Repeater requires you to place # (hash sign) before and after the name of variables.
Use the following values:
Leave the Hidden attribute unselected and click Insert Element.
Once you insert Repeater, you need to add field values from the "Repeater" variable:
Next, let's add a payment details section to the "Sales Quote" Sheet.
The payment details section contains some simple info from your Salesforce org which you inserted using Template Builder.
You can also add the "Code" element that can be used directly from mobile banking applications, for example. But, don't forget to create the corresponding field in Salesforce, filled with the content required by the corresponding code type.
To insert the payment code, follow the next steps:
Select a cell in the document where you would like to insert your code and click the "Refresh" button in Template Builder
Select the "Code" element.
Use the following values:
The "Code" (and "Image") elements have the "Inside cell" parameter. If set to "true" then the element will be resized to fit inside the cell. You can read more about element attributes on the "Element Reference For Google Sheet" page.
Leave the remaining attributes empty and click Insert Element.
Expression Builder lets you create expressions (similar to formula fields in Salesforce) without needing a formula field. You don't have to build formula fields which are only going to be used in your sheets. Instead, you can create them directly in your sheet!
Here are a few examples of what you can do using Expressions and Expression Builder:
You can read more about expressions and their syntax on the "Expressions" page.
Let's see how you can create a simple expression. You are going to add an expiration date to the quote. In the example, it expires 30 days after the quote (document) has been generated. Place the cursor where you want your date to be inserted, and follow the next steps:
Open Expression Builder from the sidebar.
Click on the icon in the bottom left of the expressions input field to open Expression Builder.
First of all, you can see all the available functions in the "Select function" menu. The first dropdown menu filters functions by categories (date, number, string, etc.), and the second dropdown menu contains filtered functions you can use.
You can also insert your Salesforce fields into expressions by using the dropdown in the "Insert field" menu (an arrow (>) next to a field suggests that it's a relationship field - e.g. Account > Contact > ...).
Before inserting a function or a field, verify that you've selected the text you want to replace in the text field below.
From the "Select function" menu, choose Date and then choose addDays. Click Insert.
You are going to replace DateTime in the expression with the current date (which is a function). From the "Select function" menu, choose Date, then Now.
Select DateTime in the text field below. Click Insert. This will replace DateTime with the "now()" function.
Replace NumberOfDays with 30.
Click Insert Expression. This inserts the expression back into the "Expression Builder" view. Click Insert Expression to insert it into your document.

Expressions can also be used within elements, on all attributes which support them. If an attribute has a switch next to it - it supports expressions. You can always read more about expressions on the "Expressions" page.
If you want to see what the actual data will be available on your Document Template, feel free to use the "Playground" tab. It can also serve as a means to debug your flow when things aren't going as they should be.
Try changing the Locale definition in your settings, for example, and see how data changes. Magic isn't it?