TASK_TEMPLATE is a custom function that enables the creation of dynamic task templates by embedding cell references, URLs, or lookup dictionaries directly into your template text. When executed via the sidebar Run button, it converts the template into a JSON string that the back-end processes to paste the rendered output into a cell and, optionally, generate a Google Doc or text file.
=TASK_TEMPLATE(template, [output_doc_name], [output_textfile_name], [celladdress])
Parameter | Data Type | Required | Description |
---|---|---|---|
template |
|
Required | The input template that contains text and placeholders (e.g.,
|
output_doc_name |
|
Optional | The name for a new Google Doc. If provided, a new document is created with the rendered result and a hyperlink is added to the cell where the function is run. |
output_textfile_name |
|
Optional | The name for a new text file. If specified, a new text file is created with the rendered output and a hyperlink is added to the sheet. |
celladdress |
|
Optional | The cell address where the rendered output should be placed (e.g.,
|
When you include a non‑empty string for output_doc_name, the function creates a new Google Doc with the rendered output and places a hyperlink in the respective cell.
=TASK_TEMPLATE("Hello {A1}", "My Story")
Providing a name for output_textfile_name creates a text file with the rendered output and adds a hyperlink to this file in your sheet.
=TASK_TEMPLATE("Report data: {A1:A5,B1:C5}", "", "output.txt")
You can override the default output location by explicitly setting the celladdress parameter.
=TASK_TEMPLATE("Summary for {A1}", "", "", "D2")
This example demonstrates how to generate a personalized greeting using cell references.
=TASK_TEMPLATE("Hello {A1}, your score is {B1}.")
Expected output:
The placeholders
{A1}
{B1}
This example shows how to generate a Google Doc from a sales report template.
=TASK_TEMPLATE("Sales Report for {A1}:
Total Sales: {B1}", "Monthly Report")
Expected output:
The template is rendered using the values from A1 and B1. A new Google Doc named “Monthly Report” is created and a clickable hyperlink is added to your sheet.
This example renders a template using a lookup dictionary and places the output starting at a designated cell.
=TASK_TEMPLATE("Data snapshot: {A1:A5,B1:C5}", "", "snapshot.txt", "E3")
Expected output:
A text file named “snapshot.txt” is created with the rendered content, and a hyperlink to this file is placed starting at cell E3.
"C1"
If you encounter an error like "Missing required parameter: 'template'", ensure that the first parameter is not empty.
Double-check that the celladdress is enclosed in quotes and follows A1 notation (e.g.,
"C1"
Verify that the referenced cells exist and contain data, and that there are no formatting errors in your placeholder syntax.
If a Google Doc or text file isn’t created, ensure you have the necessary permissions to create files in your designated Drive folders and that the file name is entered correctly.
If the returned JSON string produces an error when the Run button is clicked, review the error message to identify which parameter may be misformatted or missing.
A: You can use cell references (e.g.,
{A1}
{A}
{https://www.example.com}
{https://www.example.com|markdown}
{1d-oC-6Whej0jjdknMqw6r2WmqfdSLijS}
{A1:A5,B1:C5}
A: Yes. Since TASK_TEMPLATE creates a JSON configuration, you need to click the Run button in the Sheet Workflows sidebar to re‑execute it.
A: Certainly. Both output_doc_name and output_textfile_name are optional. If they are omitted, the rendered template is simply placed in the specified cell or in the cell immediately to the right by default.
A: Use the celladdress parameter to explicitly set the destination cell. If it’s omitted, the add-on automatically selects the cell to the right of where the function is called.
A: An error message will indicate which parameter is missing or mis‑formatted. Review your template syntax to correct any mistakes in the placeholders.
1 month ago