How to Use Template `{{Markers}}` in Document Studio
Your Document Studio templates can include any variable field that is available as a column title in the Google Sheet. In case of Google Forms, you can use any question title as your marker and the marker should be exactly as your question title enclosed in double curly braces.
For instance, if a question in your Google Form says “What is your name”, the marker you’ll use in your document template will be {{What is your name}}
.
You can also create additional columns in the source Google Spreadsheet with formulas and use them as dynamic markers in your Google template. Let me show you an example.
Create a new column and call it Row Number. Now go to the first empty cell of that column and put this ArrayFormula function:
=ArrayFormula(if(LEN(A2:A); row(A2:A) -1;))
What we have added a column that displays the row number of the rows and we can now put {{Row Number}}
in your document templates, merged file names and Drive folder path. For instance, if you put Invoice #{{Row Number}}
in the file name, the files name would be named Invoice #1, Invoice #2 and so on automatically.
Formatting Date and Time
The same technique can be used to format date and time information for including in your templates.
Say the first column in your Google Sheet in called Timestamp and it includes the date and time when a Google Form response was submitted. Add a new column called Submission Time and add this formula in the first empty cell.
=ArrayFormula(if(NOT(ISBLANK(A2:A)),HOUR(A2:A)&":"&MINUTE(A2:A),))
You can now include the submission time in your email and document template using the {{Submission Time}}
variable field.
Standard Markers for Google Forms
In addition to standard form questions and column headers, Google Forms also support a few standard markers like:
{{Response Number}}
- Form Response number{{Form Name}}
- The name of the Google Form{{Form Url}}
- A link to the associated Google Form{{Response Id}}
- Unique response ID generated by Google Form{{Response Url}}
- Directly link to view or edit the current form submission{{Response Date}}
- The full timestamp when a form was submitted{{Respondent Email}}
- If your Google Form is capturing email addresses, this will include the email address of the form respondent.{{All Markers}}
- An HTML table containing all the form responses in a neat tabular format.
You should put {{All Answers}}
in your email body to receive a copy of the form answers in an email notification.
Amit Agarwal
Google Developer Expert, Google Cloud Champion
Amit Agarwal is a Google Developer Expert in Google Workspace and Google Apps Script. He holds an engineering degree in Computer Science (I.I.T.) and is the first professional blogger in India.
Amit has developed several popular Google add-ons including Mail Merge for Gmail and Document Studio. Read more on Lifehacker and YourStory