Skip to main content
How to save workflow variables to word template

Using workflow variables, you can automatically insert data into a pre-designed word template.

Updated this week

When using workflow automation, there are situations where you may want to save variables directly into a Word document, especially if you're generating customized documents. If you're using a Word template designed in Developer mode, this article will guide you through the steps to embed these variables in a Word template.


Business Scenarios

Saving workflow variables to a Word template is valuable in several business scenarios, such as:

  • Contract Generation: Automatically create contracts with specific company names, terms, dates, and signature fields.

  • Project Reports: Generate project reports populated with dynamic data, including project names, dates, and team details.

  • Invoices and Purchase Orders: Fill out invoices or purchase orders with item details, quantities, and prices from form data.

  • HR Documents: Create customized offer letters, employee agreements, and other HR documents based on collected employee information.

In the business scenarios above, the workflow requires saving variables to a Word template. Let’s look at how to do this effectively.


Prerequisites

To save workflow variables to a Word template, you’ll need an Approval form and a Word template:

  1. An Approval Form:

    • The approval form is part of the workflow and contains controls (input fields) that correspond to the placeholders in your Word template.

    • For example:

      • Sigle line fields like Client Name and Client Address in the approval form should align with text controls in the Word template.( Detailed information on word templates is available in next step.)

      • Date fields like Date should match date controls in the template.

  2. A Word Template:

    • In Developer Mode, create a Word template with placeholders (known as Content Controls) for each variable you want to map from the workflow.

      Learn How to create a word template on creating a Word template in Developer Mode.

    • Common types of placeholders in Developer Mode include:

      • Plain Text Content Control: For text fields like company names, project titles, etc.

      • Picture Content Control: For image fields like signatures.

    • Name Your Content Controls:

      • Click on a content control, go to Properties, and set the Title and Tag.

      • The Tag is required for identification in the workflow, which should match the variable's name. Click OK to complete the setup.


How to Save Approval Form Workflow Variables to a Word Template

  1. Configure the Generate Document Action:

    • In your workflow, add a Generate Document action to automatically populate the Word template. Refer to Generate document action.

    • Select your Word template file in the Document Template field.

  2. Map Workflow Variables to Word Template Placeholders:

    • Click on the Set Variables button or Settings to open the variable mapping window.

    • In the mapping window:

      • In the Content Control column, displays all the content controls in the selected word template (e.g., Client Name, Client Address).Check the box next to each content control you want to populate.

      • In the Control Type column, displays the control type (e.g., Text, Picture).

      • In the Value column, for each content control in the word template, map it to the appropriate variable in your workflow

      • Special Configuration for Each Control Type:

        a. Direct mapping by clicking on the drop-down box

        • Text Fields (e.g., Client Name, Client Address):

          • Map each text variable to the corresponding text Content Control in Word. This will ensure that text fields from the approval form are inserted correctly.

        • Rich Text Fields

          • Map rich text fields to Rich Text Content Controls in the Word template. This helps ensure the correct rich text format is maintained in the document.

        b. Click the toggle button to open the expression editor and create a custom expression.

        Picture Fields (e.g., Signature):

        • Map the workflow variable containing the image (such as a signature) to the Picture Content Control in Word template.

  3. Choose Generation Type:

    • In the Generation Type dropdown, choose between:

      • Single PDF file – Converts the output document to PDF.

      • Original file types – Keeps the output in the original Word format.

  4. Set Output File Name:

    • Under Output file name, enter a name for your generated document (e.g., "Generate file").

  5. Save Output File:

    • Under Save output file to, select where to store the generated document. You can save it to Variables, Attachments, or other destinations available in your workflow.

  6. Complete and Test:

    • Once configured, run the workflow with sample data to ensure the template populates correctly with the data from your form.

    • Open the submitted tab, find the workflow, open the generated document to verify that all fields are filled in as expected.

Following these steps will help you set up a seamless process for saving workflow variables to a Word template, enabling automatic and consistent document generation for various business needs.

Did this answer your question?