Flow, Power Automate, Uncategorized

Power Automate w Word Online: generate document updates

Scenario:

My client generates a summary document for applications lodged online. The generated summary could be manually edited by an officer. At the final stage of the application processing, it’s required to include additional information to the generated summary document regarding the outcome of the application. This information must be dynamically generated.

This is a process diagram below:

Multi-step document generation

As you can see, the dynamic content for a document is generated twice: once during the document creation and a second time we update the existing document to add blocks of information that are not available at the earlier phase.

The solution:

We are going to use Power Automate with Word Online (Business) connector to generate and update the summary document.

There is an article explaining how to prepare the template and discussing some limitations of the connector: https://learn.microsoft.com/en-us/connectors/wordonlinebusiness/

Step 1. Prepare a document template.

We must add all the fields to the template including fields we are going to populate later.

Add fields with unique names

I use Star/End tag for the Show As property to show you field names. Please use Bounding Box instead.

I uploaded the document template to OneDrive.

Step 2. Create a Power Automate flow to generate a summary (create)

We use Populate a Microsoft Word template action of the Word Online (Business) connector to populate the template.

For the Application record created the flow will be triggered. We make sure all the fields required for the first run are included in the action. Note the field Populate later is not populated. We keep it to be populated with the outcome at the second run.

Generate document flow

For the sample application record

A sample Application record
Successful flow run

Document generated:

Document generated

The document is populated from the Application record. The outcome field remains unpopulated until the next run. This document now can be updated manually. Let’s add some content and then save.

Add manual content to the generated document

Step 3. Create a Power Automate flow to generate an outcome (update)

Before we start building the update flow, in the original flow add some text to the Populate later field. Click on than Peek code.

Find the correspondent parameter for the Populate Later field. In my case, it’s “dynamicsFileSchema/1762023507”. Save it.

dynamicFileSchema parameter name

The second flow is triggered on a status change. If the status is Outcome Received.

Let’s see what’s inside!

Getting the Application number

We need to fetch the Application number to construct the correct file name.

In the Populate a Microsoft Word template step/action we play a couple of tricks.

First, we construct the dynamic file name using the data we retrieved in the previous step.

Second, that dynamicsFileSchema we saved, remember?

Let’s construct a JSON like in the screenshot below, using the dynamicsFileSchema values as a key and Outcome retrieved for the record as a value.

Populate the updates

In the last step, we just update the file with the content from the generation step.

Update flow

Let’s run the flow and see results!

Successful run

Hocus-pocus!

You could see the file content contains the details from the first run, the manual updates, and the second run updates.

The conclusion:

As we can see, it is possible to generate document updates populating dynamic values with the data which is not available yet during the document creation. Sounds like black magic but it works! 🧙‍♀️

1 thought on “Power Automate w Word Online: generate document updates”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s