> ## Documentation Index
> Fetch the complete documentation index at: https://docs.flowforma.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Document templates

> Upload and edit Word document templates, insert flow, step, and question attributes, validate them, and use external fragments for dynamic content.

To upload a document template, go to **Document templates**. You can upload an existing Word document or create a new one.

When you add a document, make sure you give it a title and select the associated flow, otherwise you won't be able to use the [Generate document](/product/creating-flows/business-rules/business-rule-types/communications-rules/generate-document) business rule to generate the document.

To do this, hover over the row, click the three dots, and select **Details**.

<img src="https://mintcdn.com/flowforma/v8UMuZxCjEz54jQV/images/product/document-generator/document-templates/document-templates-1.png?fit=max&auto=format&n=v8UMuZxCjEz54jQV&q=85&s=0052161003b5cdfb7b57c7055490a9b7" alt="Opening a document template's details from the three-dot menu" width="922" height="741" data-path="images/product/document-generator/document-templates/document-templates-1.png" />

A new panel opens on the right-hand side, allowing you to populate the missing information.

<img src="https://mintcdn.com/flowforma/v8UMuZxCjEz54jQV/images/product/document-generator/document-templates/document-templates-2.png?fit=max&auto=format&n=v8UMuZxCjEz54jQV&q=85&s=509d3ecf4f21387f0ac90e2d18948ec5" alt="The document details panel" width="284" height="812" data-path="images/product/document-generator/document-templates/document-templates-2.png" />

* **Title**: enter the name by which the document will be referenced in the system.
* **Flow**: select the flow you want to associate the document template to. Only one flow can be selected.

## Edit document template

To edit a document template, go to **Document templates** and click the three dots beside the document you want to edit. Select **Edit** and then click **OK**. The document opens in edit mode.

<img src="https://mintcdn.com/flowforma/v8UMuZxCjEz54jQV/images/product/document-generator/document-templates/document-templates-3.png?fit=max&auto=format&n=v8UMuZxCjEz54jQV&q=85&s=2d0ba68acb9b9a556351f721a0ecc96e" alt="Opening a document template in edit mode" width="697" height="299" data-path="images/product/document-generator/document-templates/document-templates-3.png" />

Select **FlowForma** from the Office ribbon.

<img src="https://mintcdn.com/flowforma/v8UMuZxCjEz54jQV/images/product/document-generator/document-templates/document-templates-4.png?fit=max&auto=format&n=v8UMuZxCjEz54jQV&q=85&s=04f8f52dec065efb2dfbc56e4eed57e4" alt="The FlowForma tab in the Office ribbon" width="764" height="140" data-path="images/product/document-generator/document-templates/document-templates-4.png" />

In the ribbon you'll see the following three icons:

<img src="https://mintcdn.com/flowforma/v8UMuZxCjEz54jQV/images/product/document-generator/document-templates/document-templates-5.png?fit=max&auto=format&n=v8UMuZxCjEz54jQV&q=85&s=5ec298afede49124f90c190f3bf3e8c7" alt="The Panel, Validate, and External fragment icons" width="779" height="147" data-path="images/product/document-generator/document-templates/document-templates-5.png" />

* **Panel**: shows a tree view of the flow on the right side of the screen (see image below).
* **Validate**: activates after you click **Panel**; use it to check whether the document is still valid.
* **External fragment**: activates when you click an inserted attribute in the document.

## The panel

The FlowForma panel is located on the right side of the screen, and the flow elements fall into three categories:

* **Flow level attributes**:
  * **Completed**: the date and time when the flow was completed.
  * **Started**: the date and time when the form was created.
  * **Title**: the name of the flow.
* **Step level attributes**:
  * **Assigned to**: the person responsible for completing the step.
  * **Title**: the name of the step.
  * **Description**: the text inserted in the **step description** in the step definition.
  * **Comments**: the text inserted in the **comments** field of a step when a form is created and the step submitted.
* **Question level attributes**:
  * **Question code**: the question code from the question definition.
  * **Title**: the name of the question.
  * **Answer**: the information entered in the form as an answer to a question (e.g. question: "New employee name", answer: "Joan Doe").
  * **Description**: the text inserted in the **description** field of the question definition.

<img src="https://mintcdn.com/flowforma/v8UMuZxCjEz54jQV/images/product/document-generator/document-templates/document-templates-6.png?fit=max&auto=format&n=v8UMuZxCjEz54jQV&q=85&s=1ee56d54584280160a3abb85529c21d0" alt="The FlowForma panel showing flow, step, and question attributes" width="1094" height="1116" data-path="images/product/document-generator/document-templates/document-templates-6.png" />

To include FlowForma panel items (attributes) in the document, place the cursor at the required location in the Word document (this may be on a separate line, in a table, between words in a paragraph, or part of a bulleted list), move to the FlowForma element required, and double-click the item. The item now appears in the document. Continue until all relevant elements have been included. All FlowForma attributes are displayed between square brackets `[ ]`.

<img src="https://mintcdn.com/flowforma/v8UMuZxCjEz54jQV/images/product/document-generator/document-templates/document-templates-7.png?fit=max&auto=format&n=v8UMuZxCjEz54jQV&q=85&s=df6276b7ed822b24214c597234ca69f5" alt="FlowForma attributes inserted in the document, shown between square brackets" width="1094" height="379" data-path="images/product/document-generator/document-templates/document-templates-7.png" />

### Repeating table panel details

The repeating table is the only question type that includes sub-questions. If you expand the repeating table question, you'll see a new line, "SubQuestions". You can expand this area to see all sub-questions. Each sub-question has the same question attributes as any other question.

<img src="https://mintcdn.com/flowforma/v8UMuZxCjEz54jQV/images/product/document-generator/document-templates/document-templates-8.png?fit=max&auto=format&n=v8UMuZxCjEz54jQV&q=85&s=ce88f845014258414bd7deac96d73d5b" alt="A repeating table question expanded to show its sub-questions" width="227" height="268" data-path="images/product/document-generator/document-templates/document-templates-8.png" />

When you double-click or right-click on the answer in a repeating table question, two options appear:

<img src="https://mintcdn.com/flowforma/v8UMuZxCjEz54jQV/images/product/document-generator/document-templates/document-templates-9.png?fit=max&auto=format&n=v8UMuZxCjEz54jQV&q=85&s=f1437a2dd126a210c633b1f9e1cddbf4" alt="Repeating table and Repeating section options" width="357" height="99" data-path="images/product/document-generator/document-templates/document-templates-9.png" />

**Repeating table**: the entire table is exported into the document. The heading of each column equals the sub-question title, and the values in each row equal the answers of the sub-questions.

In the example below, you can see how the repeating table is displayed in the document template:

<img src="https://mintcdn.com/flowforma/v8UMuZxCjEz54jQV/images/product/document-generator/document-templates/document-templates-10.png?fit=max&auto=format&n=v8UMuZxCjEz54jQV&q=85&s=71eaf8c6c7dab09cd1754b964f22475a" alt="A repeating table in the document template" width="656" height="77" data-path="images/product/document-generator/document-templates/document-templates-10.png" />

And how the table is displayed in the final document:

<img src="https://mintcdn.com/flowforma/v8UMuZxCjEz54jQV/images/product/document-generator/document-templates/document-templates-11.png?fit=max&auto=format&n=v8UMuZxCjEz54jQV&q=85&s=f31f7c888a02f207746fd990d83b979c" alt="The repeating table in the generated document" width="641" height="77" data-path="images/product/document-generator/document-templates/document-templates-11.png" />

**Repeating section**: the entire information from the table is inserted as a text box.

In the example below, you can see how the information is displayed in the document template:

<img src="https://mintcdn.com/flowforma/v8UMuZxCjEz54jQV/images/product/document-generator/document-templates/document-templates-12.png?fit=max&auto=format&n=v8UMuZxCjEz54jQV&q=85&s=973ba8a16274fa08781119e95c8b5605" alt="A repeating section in the document template" width="644" height="191" data-path="images/product/document-generator/document-templates/document-templates-12.png" />

Below is how the information is displayed in the final document. For each row in the table you have a section in the text box, and each section contains all the sub-question titles:

<img src="https://mintcdn.com/flowforma/v8UMuZxCjEz54jQV/images/product/document-generator/document-templates/document-templates-13.png?fit=max&auto=format&n=v8UMuZxCjEz54jQV&q=85&s=44c07b5693c48164c8f643cb3dcfddd5" alt="The repeating section in the generated document" width="147" height="285" data-path="images/product/document-generator/document-templates/document-templates-13.png" />

Both table and text box attributes can be added or removed. You can also use Microsoft Word options for styling and page breaks.

<img src="https://mintcdn.com/flowforma/v8UMuZxCjEz54jQV/images/product/document-generator/document-templates/document-templates-14.png?fit=max&auto=format&n=v8UMuZxCjEz54jQV&q=85&s=bd5999f9571fdf843afd42173a4ef2c8" alt="Adding or removing table and text box attributes" width="579" height="89" data-path="images/product/document-generator/document-templates/document-templates-14.png" />

## Validate

Use the **Validate** button to check for any inconsistencies between the document template and the flow. In the example below you can see the warning message. Data from the document that is no longer valid shows up in red, meaning the information has been deleted.

<img src="https://mintcdn.com/flowforma/v8UMuZxCjEz54jQV/images/product/document-generator/document-templates/document-templates-15.png?fit=max&auto=format&n=v8UMuZxCjEz54jQV&q=85&s=3782f4a5db9be9f82b7afd365948fe15" alt="The validate warning highlighting invalid data in red" width="728" height="301" data-path="images/product/document-generator/document-templates/document-templates-15.png" />

## External fragments

External fragments let you dynamically generate documents based on different document templates, by referencing the document template URLs.

To include a document fragment in your document template, insert a FlowForma attribute in the document. Click the attribute to activate the External fragment icon in the ribbon, then click the icon. In the window that opens, check the **External fragment** option and insert the link to the document template you want to use. When you insert the document URL you have two options:

* If you only use one document, insert the exact name of the document.
* If you use multiple documents, you can use the `{value}` token. When you use this token, the document generator automatically picks the answer of the question and maps it to the document template to be inserted in the generated document.

<img src="https://mintcdn.com/flowforma/v8UMuZxCjEz54jQV/images/product/document-generator/document-templates/document-templates-16.png?fit=max&auto=format&n=v8UMuZxCjEz54jQV&q=85&s=da16c73ed8ffc89bb02d811d6ca4bc78" alt="The external fragment options window" width="709" height="476" data-path="images/product/document-generator/document-templates/document-templates-16.png" />

### Example

In a "new employee" flow, one of the steps is to generate the contract of employment and populate it with the job description of the new employee. The target question "position" has three job titles: Business Analyst, IT Manager, and HR Assistant.

<img src="https://mintcdn.com/flowforma/v8UMuZxCjEz54jQV/images/product/document-generator/document-templates/document-templates-17.png?fit=max&auto=format&n=v8UMuZxCjEz54jQV&q=85&s=5d49597a6a4871d9069ef25df4dfdd51" alt="The 'position' target question with three job titles" width="754" height="794" data-path="images/product/document-generator/document-templates/document-templates-17.png" />

In the document templates library there are four document templates:

* Contract of employment template
* Business Analyst: contains the business analyst job description
* IT Manager: contains the IT manager job description
* HR Assistant: contains the HR assistant job description

The document you generate is the contract of employment. Based on the information selected in the "position" question, the generated document displays the correct information. Note that the document templates must have the same name as the choice values in the question.

If you select "Business Analyst" in the flow, the job description from the "Business Analyst" document template appears in the responsibilities area of the newly generated document, as shown below.

<img src="https://mintcdn.com/flowforma/v8UMuZxCjEz54jQV/images/product/document-generator/document-templates/document-templates-18.png?fit=max&auto=format&n=v8UMuZxCjEz54jQV&q=85&s=ddded240ebe7d087b6f46eddcb3d6090" alt="Generated contract showing the Business Analyst job description" width="612" height="630" data-path="images/product/document-generator/document-templates/document-templates-18.png" />

If you select "IT Manager" in the flow, the IT Manager job description is displayed.

<img src="https://mintcdn.com/flowforma/v8UMuZxCjEz54jQV/images/product/document-generator/document-templates/document-templates-19.png?fit=max&auto=format&n=v8UMuZxCjEz54jQV&q=85&s=b5c588ba4693cee93d73a760140aa621" alt="Generated contract showing the IT Manager job description" width="664" height="577" data-path="images/product/document-generator/document-templates/document-templates-19.png" />

<Info>
  When you use multiple document templates to generate a document, it's recommended that you use the same document formatting, otherwise the formatting won't be consistent, as you can see in the previous two images.
</Info>
