Dynamic Contract Generation via Template

 

This document provides steps to setup a Dynamic Contract using Templates, which includes preparing your template document, managing conditions and mapping, and ability to quickly auto generate contract drafts.

Note that, we have integrated Templates Module into Pre-Signature. As an Admin user, you can store your Templates in one primary location, and from there, you can connect them to your Pre-Signature workflows.

 

Prerequisites (Creating a Template for Pre-Signature)

  • Setup your contract request form using our primary Contract Request form. Frame all questions in your form to help gather all the right information from the Requestor. Learn more here.
  • Prepare your document in a correct format to ensure that it functions seamlessly with dynamic contracts. Make sure that you follow the template standard rules and clean up your template as mentioned in the Template Creation Guidelines section.

Manage Conditions and Mapping

Watch the video below and follow the detailed steps to understand how to generate contracts dynamically using Document Tags.

 

Step 1: Update and Add the Template

Update the document template with Document Tags and Conditional Variables as mentioned here. Use the Template module to Add a new Template and upload the document template.

add template.gif

 

Step 2: Decide When to Auto-Generate the Template

To configure when the template should be auto-generated, you can set up rules and add multiple conditions where, they all follow the AND logic. The template will be selected only if all the conditions match.

  1. In the Templates Module, navigate to the uploaded template.

  2. Against the template, click the three vertical dots menu and select Manage conditions and mapping.

  3. In the General tab:

    • The Active toggle is on and indicates that the template is active. If the template is no longer needed in auto generation, it can be made inactive.

    • The Auto-generated and email the contract to requestor on request submission toggle is on to automatically email the auto-populated template to the Requestor upon form submission. The contract status will be auto set as "Waiting for Signature”.
      When turned off, the draft is not automatically generated and the Requestor will not receive an email with the draft attached. However, the Assignee can still manually generate the draft at any time by clicking the Download Auto-Populated Draft button. This option is useful when you want to keep the automation framework in place while preventing immediate access to the draft by the Requestor.

    • In Select File Format for Auto-generated Contract choose the output format of the auto-generated contract that best suits your needs: 
      • PDF (non-Editable) - Generate a read-only PDF version of the contract, ideal for sharing finalized documents that cannot be modified.
      • DOCX (Editable) - Generate a Microsoft Word document (.docx) version of the contract, allowing you or your recipients to make edits as needed.
        Note: To help prevent duplicate configurations across different templates, the system checks for duplicate condition settings when you create or modify a template. If a duplicate is found, you’ll receive a warning message.
        formats auto generate.png
  4. In the General Tab, map the form questions to the variables present in the document:

    1. In the Form Question drop-down list, select the form value.

    2. In the Operator drop-down list, select the operator value. The operator value is updated based on the Form Question selected.

    3. In the Value field, select the value for the form question. The field can be a drop-down list or a free text box based on the Form Question.

    4. To add multiple form questions, click the + icon. Add a new Form Question, Operator and Value.

  5. Click Next.

General tab.gif

 

Step 3: Map Form Fields to Templates

To ensure a seamless integration between your form and the template, map template fields present in the document to the form questions.

  1. In the Field Mapping Tab, the Document Tags are displayed from the tags that were added to the document template.

  2. Map the Template fields to the Form Question.

  3. Click Next.

Note: If fields are mapped then the value from form response is replaced in the document. Any Document Tags that are not mapped to a question will be displayed as is in the document with brackets.

Step 3 field mapping.gif

 

Step 4: Dynamically Render Text Based on Form Inputs

Here, you can configure rules to map form questions to specific values. This allows you to set up conditional business rules that automatically include or exclude text based on form inputs. Multiple conditions can be added, and they follow the AND logic. The text will only display when all the conditions are met.

  1. In the Conditional Logic tab, the Tag names with the text is displayed from the Conditional Variables that were added to the document template.

  2. Map the Form Question and Values.

  3. Optionally, to add multiple form questions, click the + icon. Add a new Form Question, Operator and Value.

  4. Click Save to save your configurations and apply them effectively.

Note: If the content is not mapped to a question, the Conditional Variable will be displayed as is in the document with brackets.

step 4 conditional.gif

 

Template Creation Guidelines

Important Things to Remember

Before you begin creating a template it is important that you clean up your template and update the template as mentioned in Rules and Conventions.

Rules and Conventions

Cleaning Special Characters

Before adding any template variable, it's essential to clean up special characters within your document.

If {{ {% %} }}are seen in the document, you need to clean up the document as below:

  • {{ to be replaced using {_{

  • }} to be replaced using }_}

  • {%  to be replaced using {_%

  • %} to be replaced using %_}

Variable Types

  • Document Tags: To enable dynamic form data insertion, use {{ variable }} in your document where you want form input values to replace them.
    For example: {{ effectivedate }}, {{ customername }}, {{ address }}.

  • Conditional Variable: Conditional variables allow you to implement dynamic content in your documents based on specific form values. To achieve this, you can use the following syntax:
    {% if variable %} Text to be shown or hidden {% endif %}.

    For example: Suppose you want to include a "Force majeure" clause in a contract template if the contract is for a 'Customer'. You can add the following code to your template:
    {% if account_type %}
    12. Force majeure: The seller shall not be liable for any delay or failure to perform its obligations under this contract if such delay or failure is caused by a force majeure event.
    {% endif %}
    In the auto-generated document, the "Force majeure" clause will only be included if the form response indicates that the contract is for a 'Customer'. For other account types, it won't be added.

    Note: Conditional content can span multiple lines to cater to your specific document customization needs.

Variable Naming

Variable names should consist solely of alphabetic and numeric characters. If necessary, you can use underscores (_) within the variable name. However,

  • Variable names cannot start with a number
  • Spaces and special characters are not allowed.

No Nested Variables
Nested variables are not supported within this template system. Each variable should stand alone and not be contained within another variable.

Nesting Document Tags in Conditional Variable
Support for nesting document tags in conditional variables allows the automatic population and visibility of the document tag when the associated conditional variable is true.
Note: Conditional content can span multiple lines to cater to your specific document customization needs except when applied in a table. In such cases, please confine the conditional text within the cell.

Distinct Variable Names

Ensure that variable names are distinct for document tags and conditional variables. This distinction helps in clear identification and usage.

Flexible Formatting

Auto-generation template variables can be applied to various styles and formatting within your document. (But not for the Document Tags and Conditional Variables)

Limitations

  • Keep the styling consistent for all the characters in a variable. If the style is not maintained as expected the generated document might be wrong.

  • The variable must all be in lowercase with no spaces.

  • Only paragraphs, tables, headers, and footers are supported for variables.

  • Any variables/tokens added to any other section may lead to breaking of document generation.

  • Images may not be maintained on the output generated docx file.

  • Ensure that variables/token names are distinct from Form Field variables and Conditional Variables.

  • If any type of special styling or formatting or wizards are added in one type of editor (for example, Google Docs) and it's not present in another editor (for example, Word Docs, LibreOffice) when the file is opened, the special styles would revert to base/common styles.

  • Basic variables should have only the variable inside the brackets, else output maybe unexpected.

  • If any variable is left unmapped to a form field, that variable will be shown as empty in the generated output.

  • If any field mapped to a variable is empty, then the variable will be shown as empty in the generated output.

  • It is recommended to use format painter of already present text and apply it on the entire variable part to maintain the formatting of the document.
    For example: 
    <Some text> … {{ basic_variable }} … <some text> (->apply format painter on {{ basic_variable }} )
    <Some text> … {% if conditional_variable %} …<conditional text>… {% endif %} …<Some text> (-> apply format painter on {% if conditional_variable %} and {% endif %} )
  • Tokens added inside bullet items, will not be picked for token fetching and processing during auto-generation, causing the space occupied by the variable to go blank, unless the same variable is used elsewhere (paragraph texts, tables, sections) in the document.

Frequently Asked Questions

Q: The page fails to open and displays "Oops! Something went wrong. Please refresh this page & try again." What actions should I take?

A: This issue typically arises when the uploaded template is not a valid Word document. Please download the template from the platform, open it in Google Docs or Microsoft Word, then export/re-save it again as a .docx file (via File → Download → Microsoft Word) before re-uploading. 
 

Q: All templates within a folder fail identically, appearing as a "global" issue. What is the cause?

A: This generally indicates that the folder contains files that appear as .docx but are in fact different formats, such as Word theme files, PDFs, or legacy .doc files renamed with a .docx extension. Please re-save each template using Microsoft Word or Google Docs as authentic Word .docx files prior to re-uploading.
 

Q: The template fails to open in Microsoft Word as well. Why does the platform fail?

A: This indicates the file is corrupted or damaged. Acquire an uncorrupted copy, save it again as a Word .docx, and re-upload.
 

Q: My template is password-protected or encrypted. Is it compatible?

A: No. The platform does not support password-protected Word documents. Please remove the password protection, save the file, and re-upload.
 

Q: My template contains merge fields such as {% if ... %} or {{ token }}. Could these cause errors?

A: Yes. If a merge field has a missing closing tag (e.g., {% if %} without a corresponding {% endif %}) or contains typographical errors (e.g., {{ token } instead of {{ token }}), the platform cannot parse the template, resulting in a failure to load the page. Please open the template, correct any unclosed or mistyped placeholders, and re-upload.
 

Q: Two users open the same template simultaneously; one encounters an error. Why?

A: When two users access Manage Conditions and Mapping on the same template concurrently, the platform temporarily locks the template for one user until the other completes their session. Please wait 10 to 20 seconds and attempt to reload; the page should then open.
 

Q: The page functioned correctly yesterday but today displays "Oops!" with the message No Template Changes. What is the cause?

A: This typically reflects a transient platform issue, such as temporary loss of access to file storage or elevated server load. Please refresh the page and retry after a brief interval. Should the problem persist after multiple attempts, submit a support ticket for further investigation.
 

Q: The page opens, but the mapping list is empty or tokens appear incorrect. Is this related?

A: This is a related but distinct issue, not a crash. It indicates that the template was previously processed in an invalid state, resulting in stale or incomplete saved data. Please re-upload the template as a new .docx file to force the platform to re-parse it; the mappings should then load correctly.
 

Q: After re-uploading the corrected template, some merge-field tokens are missing from the mapping list. Why?

A: Token names containing spaces, special characters, or non-English letters are not recognized by the mapping engine and are therefore omitted. Please rename tokens to include only letters, numbers, and underscores (e.g., customer_name instead of customer name), save the template, and re-upload.
 

Q: I uploaded a very large template and now the page fails. What is the reason?

A: The platform accepts Word .docx files up to a maximum size of 20 MB. Larger files are rejected. Additionally, files approaching this size limit that contain numerous images or large media elements may exceed processing memory limits, causing the Manage Conditions and Mapping module to fail. To resolve this, compress or remove extraneous images, save the file again as a .docx, and re-upload.
 

Q: How can I prevent these issues from occurring?

A: Prior to uploading, always open the template in Microsoft Word or Google Docs and utilize the "Save As" or "Download as" function to export the file explicitly as a Word Document (.docx)—even if the file already has a .docx extension. Renaming a file's extension (e.g., changing .thmx, .doc, or .pdf to .docx) does not alter its format and is the most frequent cause of errors. Additionally, maintain simple merge-field syntax and restrict token names to letters, numbers, and underscores.
 

Q: None of the above scenarios corresponds to my issue. What should I do?

A: Please submit a support ticket including the template name, customer account details, timestamp of the error, and a screenshot. Also, provide a summary of attempted resolutions to facilitate efficient investigation by our support team.