Template Syntax Overview

The 'Populate Word Document' Power Automate action enables you to populate a word document (DOCX) with data derived from a JSON document.

Basic 'Populate Word Document' Example

To use the 'Populate Word Document' Power Automate action, you'll need to pass the following information:

  1. File Content: The Microsoft Word Document (DOCX) to populate.
  2. Document Data: The JSON data to populate the document with.

If you are not familiar with JSON we recommend the following resource: JSON Introduction

Consider the following simple JSON object:

{
"companyName":"Encodian"    
}

Configuring a word document to receive this data is very simple, just simply use this syntax to add a 'token':

<<[propertyName]>> 

NB: the property / token name must start with a letter, not a number.

Example Document: Encodian - Template Syntax.docx

You do not need to add content controls or similar, you simply need to add some placeholder text to the document wrapped in the template syntax as a 'token', for example:

mceclip0.png

Configuring Power Automate is also very simple, consider the following flow:

mceclip1.png

Upon executing the flow, the Encodian population engine will automatically detect all tokens which should be replaced with the data contained within the JSON data provided, see below:

mceclip2.png

Document Content Formatting

Example Document: Encodian - Template Syntax - Formatting.docx

The data added to the document will automatically assume the formatting which has been applied to the token, for example:

mceclip5.png

Generate the following output:

mceclip4.png

You must ensure the formatting is applied to the token and not the property inside the token, for example, the following will not work:

mceclip6.png

Have more questions? Submit a request

3 Comments

  • 0
    Avatar
    JBenjamin

    Is it possible to update a Word document after the initial "populate" flow action has been performed? 

    Here are a couple of examples: 

    1. After a request gets approved, the document is updated to include the approval history & comments. 
    2. A Word-based form we use is sometimes submitted on behalf of a department other than the submitter's own department, and if the submitter forgets, the form is sent back.  The submitter then updates the department code in the list item, and we take that change and update the Word document.

    I cannot get Encodian's "populate Word doc" flow action to handle either scenario.  It seems that after the first run of the flow action, the tokens are removed (whether used or not).  We also have used Plumsail, and that works for both scenarios stated above, but we are hoping to reduce the number of 3rd party flow actions we're using. 

    I also tried using the "search and replace text" flow action, but it only works if you capture the original text somewhere first and know what it is exactly.  

  • 0
    Avatar
    Alex Rackwitz

    Fakhruddin Rangwala - thanks for your comment. We are working on Populate PowerPoint and Populate Excel actions. Stay tuned :)

  • 0
    Avatar
    Jay Goodison

    JBenjamin

    The merge tokens are removed during the initial document population therefore the document cannot be populated again. Here is how you would address your scenarios:

    Scenario 1:
    If its a separate sheet you are inserting, you could populate an approval and comments sheet and merge this word document with the original document (Merge Word Documents – Encodian Customer Help).

    Alternatively, to update Word documents using Populate Word, run the action with the original JSON data and add any desired updates i.e. populate the original template with all the required data.

    Scenario 2:
    Again, you can update the word document by re-populating the original template with all the data but the department code changed. You can also replace a department code in the document using Search and Replace Text – Encodian Customer Help but you will have to store the original value as you mention. 

    Edited by Jay Goodison
Please sign in to leave a comment.
Powered by Zendesk