Create Documents with Power Automate

Complete guide, demonstrating how to create new Word Documents based on a template, and any combination of text, images, documents and tables.

Objective

In this example we’ll be achieving the following objective with a fictional organisation named “10docs Ltd”.

10docs is working to professionalise the way they invoice their clients. They have worked on a new Word based Template (Word Invoice Template) that includes their branding, a layout, and the basic content they would like to use.

The template looks like this:

Setup

Power Automate is a growing platform, with an enormous number of first and third party connectors. Tendocs works with them all.

To keep it simple, this example uses the following connectors:

  1. SharePoint for Template storage

  2. SharePoint and Excel for Tables

  3. SharePoint and Variables for Text

  4. SharePoint and Variables for Tables

  5. SharePoint for Image and Sub-document storage

  6. Tendocs for Creating the Document.

If you need any help along the way, feel free to reach out to the support team.

Assets

So you can test this yourself, exactly as described here, you can download copies of all the assets used. To get started, all you need is a SharePoint site with a Document Library.

  1. the Terms and Conditions document.

In addition to the above, some steps are shown using information from SharePoint Lists. The definition of these will be shared later.

Build

Preparing the basics (Images and Documents)

To keep things simple, we’re going to start with what Microsoft calls an “Instant Cloud Flow”. It means we can run the flow at the click of a button.

  1. Go to the Power Automate home page.

  2. Create a new Flow “Instant Cloud Flow”, and then complete as follows.

  1. Add a “Get File Content” action to the Flow, and then reference the company logo.

  1. Rename the action to “Company Logo” to make it easier to work with later.

  2. Add another “Get File Content” action, select the “Client Logo". Rename the action to “Client Logo”.

  3. Add another “Get File Content” action, select the “Terms and Conditions” document. Rename the action to “Terms and Conditions”.

  4. Add another “Get File Content” action, select the “Word Invoice Template”. Rename the action to “Word Template”.

The references to the files so far have been static, however, in the case of the client logo, this would be dynamic can come from a “Clients” list, or some other source. You might also have different office templates foe the invoice, and even different company logos. All of this is possible with Power Automate, but beyond the scope of this simple demo.

Preparing the invoice line items (Table)

The invoice line items can be sourced from a number of different places. Tendocs is flexible enough to work with them all. Provided below are common examples to get you started.

You can retrieve table information, in this case the invoice line items, directly from a Table in an Excel file. You could do it by having a dedicated file per invoice, or, by performing a dynamic filter using the capabilities provided by the Excel connector.

  1. Add the “List rows present in a table” Excel (Business) action, select the SharePoint Site, Document Library, and then the Excel File. Choose the “InvoiceLines” table, and then for example add a filter to retrieve only those items for a specific invoice.

  1. Rename the action to “Invoice Line Items”.

Preparing the simple text replacements (Text)

The most common feature of a template is being able to replace simple text values. These too can be sourced from a number of different places. Tendocs is flexible enough to work with them all. Provided below are common examples to get you started.

You can retrieve text replacement information from a Table in an Excel file. It could be a dedicated file, but more likely one with a table containing information about all invoices which is filtered using the capabilities provided by the Excel connector.

  1. Add the “Get a row” Excel (Business) action, select the SharePoint Site, Document Library, and then the Excel File. Choose the “Invoices” table, and then select “ID” for the “Key Column” and 1 for the “Key Value”.

  1. Rename the action to “Invoice Details”.

Putting it all together with the Tendocs action

The previous steps have completed all the preparation necessary to automate the creation of invoices.

  • Both the company and client logos have been retrieved.

  • The Word Template have been retrieved.

  • The document that contains the Terms and Conditions has been retrieved.

  • The Invoice Line Items have been sourced from three possible locations.

  • The Invoice Details have been sourced from three possible locations.

The next and most important step is to put it all together using the Tendocs Documents action.

  1. Add the Tendocs “Create New Document from Template” action.

  2. The first time you add the action, you will also need to establish a new “Connection”. The new connection screen will look like the following:

  1. Enter the details as follows:

    1. Enter a new name for the connection, so that you can identify it later.

    2. The API key should come from the “Profile” page on the Tendocs website, after following the “Sign up” instructions.

    3. When complete, click on “Create”.

  2. Expand the “Show Advanced Options” link to show the following:

  1. Complete the fields as follows:

    1. Template File: “Word Template” - “File Contents”

    2. Text: “Invoice Details” - “Body”

    3. Image Token 1: “CompanyLogo”

    4. Image File Content: “Company Logo” - “File Contents”

    5. Add another image by clicking “+ Add new item”

    6. Image Token 2: “InvoiceToLogo”

    7. Image File Content: “Client Logo” - “File Contents”

    8. Document Token 1: “TermsAndConditions”

    9. Document File Content: “Terms and Conditions” - “File Content”

    10. Table Token 1: “InvoiceLines”

    11. Table Rows 1: “Invoice Line Items” - “Body - List of Items”.

      • Important: Be sure to select the “Body - List of Items” and not “Value - List of Items”.

    12. Document Format: Select the format for the document “Original”.

    13. Configuration Keys: Provides for advanced configuration scenarios.

Saving the new document

The final step is to connect an action to save the document to the location we want to store it.

  1. Add the SharePoint “Create File” action.

  2. Select the destination SharePoint site, then a Folder Path. You will need to set a filename, which will most likely require some logic to avoid overwriting other generated documents.

  3. In the “File Content” section, add the “File Content” from the Tendocs Action.

Running the new Flow to create your document

All the pieces are now in place, all that is left is to test the new flow.

  1. After saving the Flow, click on the “Test” button, select “Manually” for the trigger, and then click “OK”. You may be prompted to check or create connections, where you can “Continue” and then “Run Flow”.

  2. After a short period of time, the Flow should complete successfully, and you will find the document created with all the merged information.

The Final Result

The final result is a brand new document that is the combined result of the Word Template provided, the Images, Tables, Documents and Texts.

Download the document to see for yourself.

Last updated