---
title: "Document Templates Table"
canonical: "https://help.agiloft.com/space/SD/44433468/Document+Templates+Table"
format: markdown
---
The Document Templates table stores a record for each document template. The records include the attached template file as well as metadata about the template, such as what types of records can use the template, which records have documents generated from the template, and whether the template is available in multiple languages. In the out-of-the-box system, document templates are used to generate documents for Contracts and Sourcing Events.

# Creating Records

By default, users in the admin, Admin Import, Business Admin, and Contract Admin groups can create Document Template records. The records are owned by the user who creates them. Create records by click New in the table view action bar.

In the records, the ID, Title, Template File, and Version Number fields are pulled into the Contracts table as a link to selected fields from another table. These are filtered to Document Templates whose Available for Contract Types field contains the Contract Type selected in the current Contract record. If multiple Document Templates are available for a Contract Type, the default value for the Document Template to Generate in the Contract is matched to the Default Document Template Title and Document Template File fields of the selected Contract Type. An Abbreviation field is used in the resulting file name, so it is useful to populate any new Document Templates with a reasonable abbreviation.

You can also add a document template without contract information, variables, or formulas, to the Document Template record using the Blank Form field. This field is used to provide a template of the document, without the metadata. This option can give potential suppliers a chance to review the conditions of the document without including specific information. Essentially, the blank form should be considered as a preview of the contract terms. 

The document uploaded to the Blank Form field should not use conditions. For example, if a clause only appears in the contract for contracts valued above $10M, you should decide whether or not to include this in the blank form document as it can be sent to potential suppliers before the contract value is decided as part of the Sourcing Event. Once the Sourcing Event has a Selection Approved, a final contract is generated using the full document template. 

## Inserting Variables into Document Templates

Templates can include field variables from the table the template is related to, as well as from any table in the system. For instance, a template might have the text `$contract_start_date` in the place where the start date of the contract should appear. When you generate a document, the system replaces each field variable with the value from its corresponding field in the record.

A special syntax is used for fields and records that do not live in the table from which the template is run: `$field_from_other_table([table],[record_ID],[field])`

For example, `$field_from_other_table(clause,41,clause_text)` indicates that the Clause Text field (clause_text), for record with ID 41 in the Clause table should be inserted into the document template at this position. For more information about the syntax, see [Embedding Tables and Fields from Tables](https://agiloft-public.atlassian.net/wiki/spaces/HELP/pages/43714372).

> ℹ️ Document templates should reference the variables for clause records in the Clause Library, not the Document Template Clauses table. This is especially important for enabling proper compatibility with the Agiloft Word app.

#### Conditional Text, Fields, and Content

There are several ways to insert conditions into a document template to use alternative text or values. These are described in [Document Template Syntax Reference](https://agiloft-public.atlassian.net/wiki/spaces/HELP/pages/43714847). It’s common to have templates with optional or conditional sections that may or may not appear when a document is generated from the template, based on metadata in the record.

#### Numbering of Sections

If the document template uses HTML text fields from the contract or clauses in the clause library, and you need section numbering with the contract, there are some special challenges with deciding what kind of numbering methodology to use. Auto-numbering can be used in the HTML clause field itself, in the template, or in the style used in the conversion.

In the out-of-the-box system, numbering and indentation style is set in the document template, not the clause text. However, sometimes the HTML text that replaces the variable in the template does not retain the numbering or indentation. If you see this issue in your document templates, you can choose to insert the auto-numbering HTML code inside the clause text, instead of in the document template. To do so, edit the clause in Source HTML and insert the MS Word auto-numbering code at the front of the clause text. When the document is generated, this code automatically assigns a sequential number and applies list indentation. Note that if you use this method, these numbers are reassigned every time the document is opened, which means the clauses are always shown as recently modified when a contract is edited.

##### **Auto-numbering Code**

```
<agiloft_tag_fc fc="al_fc_start LISTNUM LegalDefault \l 1 al_fc_end"></agiloft_tag_fc>
```

For more information on how document templates interact with a clause library, see [Clause Library Table](https://agiloft-public.atlassian.net/wiki/spaces/SD/pages/44434075).

# Views

The out-of-the-box Document Templates table includes the [standard views](https://agiloft-public.atlassian.net/wiki/spaces/HELP/pages/43718574). The Default View shows the Edit icon, ID, Related To, Title, Status, Template File, and Blank Form fields. 

![Default View for the Document Templates table](media://4c88b873-ee6f-42f7-b60f-f8bf2b8acc09)

# Related Tables

The diagram below shows the default incoming table relationships and linked fields in the Document Templates table.

![Default table relationships for the Document Templates table](media://ce31a7bb-d2df-4ce3-ae64-586c514b0070)

# Fields

In addition to the [standard fields](https://agiloft-public.atlassian.net/wiki/spaces/SD/pages/44434023/Table+Concepts#standard_fields), the out-of-the-box Document Templates table includes the following fields.

| **Field Label** | **Data Type** | **Description** |
| --- | --- | --- |
| Abbreviation for File Name | Short Text | An abbreviation to add to the filename of documents created from this template. The abbreviation is added after the company name of the external party. |
| ACA Update | Choice: Yes, No | System flag that’s set to Yes when a template is updated with the Agiloft Contract Assistant for Word app. Used as conditional filter for certain rules. |
| Add Contract Type ID | Link to selected fields from other table: Contract Types | When a document template is selected for a new contract type, the system adds the contract type ID to this field and the type to the Available for Contract Types field. |
| Additional Language Templates | Related Table: Document Templates | Visible if Has Multiple Languages is Yes. Lists the other languages this template is available in besides the default language. |
| Available for Contract Types | Link to selected fields from other table: Contract Types | Visible if Related To is Contracts. Lists which contract types the template is available for. |
| Available for Sourcing Event Types | Link to selected fields from other table: Sourcing Event Types | Visible if Related To is Sourcing Events. Lists which sourcing event types the template is available for. |
| Blank Form | File with Versioning | Stores a template that doesn’t have contract information, variables, or formulas so you can create a version of the document without specific details. |
| Blank Form Attachment Type  
Blank Form Attachment Type ID  
Blank Form Attachment Type Sort Order | Link to selected fields from other table: Attachment Types | Visible if Has Variables is No. Lists the attachment type of the blank form. |
| Clauses for this Document Template | Related Table: Document Template Clauses | Lists any clauses from the Document Template Clauses table that are included in this template. |
| Contract Type  
Contract Type ID | Link to selected fields from other table: Contract Types | Lists the contract types that use this template. |
| Corresponding AI Document Type | Short Text | Identifies the AI document type used for clause extraction. When the system extracts clauses from a document created from this template, it sends this value to the AI model so the model uses the correct document type. |
| Default Approval Workflow ID  
Default Approval Workflow | Link to selected fields from other table: Approval Workflows | The default approval workflow to use for documents generated from this template. |
| Default Attachment Type  
Default Attachment Type ID  
Default Attachment Type Sort Order | Link to selected fields from other table: Attachment Types | The default attachment type for documents generated from this template. |
| Default Language  
Language ID  
Language | Link to selected fields from other table: Languages | Identifies the primary language for the template. Default is English. |
| Default Risk Rating | Integer | The default risk rating for documents generated from this template. Accepts integers from 1 – 5. |
| Default Sort Order | Floating Point | The default sort order for attachments generated from this template. |
| Description | Text | A description of the template. |
| Document Template Clause IDs | Link to single field from other table: Document Template Clauses | Lists the IDs of any clauses from the Document Template Clauses table that this templates includes. |
| English Language Template File ID  
English Language Template File  
English Language Template | Link to selected fields from other table: Document Templates | Visible if Has Multiple Languages is Yes and Default Language is not English. Identifies the English version of the template. |
| Extra Fields to Show | Multi-Choice:<br>Governing Law, Insurance, Confidentiality, Non-Solicitation Clause, Residuals Clause | Defines which additional fields or clauses to show in the template. |
| Has Conditional Clauses | Choice: Yes, No | Visible if Uses clauses is Yes. Used when generating documents from the template. When No, processing is simplified because conditions don’t need to be checked. |
| Has Multiple Languages | Choice: Yes, No | Specifies whether there are versions of the template in different languages. |
| Has Optional Clauses | Choice: Yes, No | Visible if Uses Clauses is Yes. Defines whether documents generated from this template include optional clauses. |
| Has Variables | Choice: Yes, No | Visible if Related To is Sourcing Events. Determines whether the standard Template File field is shown or the Blank Form field.<br>- When Yes, the Template File field is visible. This is the default value.
- When No, only the Blank Form field is visible. |
| Include in Merge for conversion | Choice: Yes, No | Specifies whether documents generated from this template are included when running document merge or conversion actions, such as combining multiple files into a single document or converting them to PDF. Default is Yes. |
| Instructions | File with Versioning | Stores a file that includes instructions for using the template. |
| Latest Sourcing Event Department ID  
Latest Sourcing Event ID  
Latest Sourcing Event Title | Link to selected fields from other table: Sourcing Events | System-managed fields that track the most recent sourcing event to use this template. |
| Latest Sourcing Event File | File with Versioning | If Related To is Souring Events, this field stores the latest version of the generated sourcing event document. The file is converted to an Attachment record. |
| Password for Locked Word Document | Short Text | Stores the password for opening the template. For more information, see [Locked Word Templates](https://agiloft-public.atlassian.net/wiki/spaces/HELP/pages/43714851/Creating+Document+Templates+Manually#CreatingDocumentTemplatesManually-Locked-Word-Templates) in the CLM Help. |
| Potential Clauses | Related Table: Document Template Clauses | Lists the conditional and optional clauses from the Document Template Clauses table that may be included in the template. Filtered to show clauses where Clause Usage is Fallback, Conditional, or Optional. |
| Publication Level | Choice: Contract Managers Only, Internal, Public | Defines which users can see the template. |
| Related To | Choice:<br>Sourcing Events, Documents, Company Documents, Contracts | Defines which type of documents the template is used to generate. |
| Required Fields for this Subtype | Multi-Choice:<br>Residuals Clause, Non-solicitation Clause, Insurance, Governing Law, Confidentiality, Contract Renewal Type, Main Contact, Contract Party Address, Contract Party Name, Contract Amount, Contract End Date, Contract Start Date | Specifies which fields to make conditionally required in the Contract record based on the document template. This ensures the necessary fields have values before a document is generated from the template. |
| Status | Choice: Active, Inactive | The state of the template. When Active, the template is available for generating documents. When Inactive, the template isn’t available. |
| Template File | File with Versioning | Stores the template file. |
| Title | Short Text | The name of the template. Must be unique. |
| Title for Generated Document | Text | The title to use for Attachment records created for documents generated from this template. |
| Uses Clauses | Choice: Yes, No | Controls visibility of the clause-related fields. |
| Version Number | Floating Point | The version number for the template. Defaults to 1. |

# Automation

This section describes the rules that are implemented for the out-of-the-box Document Templates table. For details about rule configuration options, see [Rules](https://agiloft-public.atlassian.net/wiki/spaces/HELP/pages/43714473) in the Help Guide.

- **Edit: Convert Latest Solicitation File (web, API)**: This rule runs when a document template related to sourcing events is edited. It creates an Attachment record for the Latest Sourcing Event File.
- **Edit: Edit actions by API or Web - add contract type (web, API)**: This rule runs when a when records are edited. If a new Contract Type was added, it adds the new type to the list of Available Contract Types.
- **Create/Edit - All Create/Edit Actions (web, API)**: This rule runs when records are created or edited. It performs any necessary status updates to Document Template Clauses.