Get Tracked Changes from a Microsoft Word Document with Power Automate

February 1st 2023
Back to all blogs

Last December, we released the ‘Get Tracked Changes‘ Power Automate action, which obtains all of the tracked changes data (comments and changes) for the Microsoft Word document provided, returning the data as JSON formatted strings.

For this post, we’ll provide a basic guide for using the ‘Get Tracked Changes‘ Power Automate action to obtain tracked changes data from a Microsoft Word document covering both the creation of a summary document and manually handling the tracked changes and comments data.

1. Create a new ‘Automated cloud flow.

1.a. Flow name: Provide a name for your flow

1.b. Trigger: Select the ‘When an item of a file is modified‘ SharePoint trigger action

1.c. Click ‘Create

2. Configure the ‘When a file is created in a folder‘ SharePoint trigger action as required.

3. Add a trigger condition to the ‘When an item of a file is modified‘ to ensure the flow is only triggered when a Microsoft Word document (docx) is modified. We’ll add this trigger condition: @endswith(triggerOutputs()?[‘headers/x-ms-file-name’], ‘docx’)

Reference: Create Power Automate Trigger Conditions Simplified

4. Add the SharePoint ‘Get file content‘ action

4.a. Site Address: Set as per the trigger actions value

4.b. File Identifier: Select the ‘Identifier‘ property provided by the ‘When a file is created in a folder‘ SharePoint trigger action

5. Add the Encodian Get Tracked Changes action

5.a. File Content: Select the ‘File Content‘ property provided by the ‘Get file content‘ SharePoint action

At this stage, it’s worth testing the flow to verify that your document has tracked changes and comments. For example, the test document I have configured contains an addition, deletion and comment:

The Encodian Get Tracked Changes action returns the changes and comments as two JSON formatted strings:

The JSON data structure for changes is depicted below:

The JSON data structure for comments is depicted below:

Note both return datasets are an array, i.e. one or more comments. There are loads of options for handling the data. The following examples are detailed below:

Create a Summary Document and attach it to an Email

The first option is to use the Encodian ‘Populate Word Document‘ action to create a summary document using the JSON data values returned by the Encodian Get Tracked Changes action.

I’ve created the following word template, which is used within this example: Encodian – Blog – Get Tracked Changes Template.docx

To create the document which can pass the JSON data provided by the Encodian Get Tracked Changes action to the Encodian ‘Populate Word Document‘ as it can natively add this data type as a repeating section, table, bulleted list or paragraph as document here:

Let’s configure the flow;

6. Add the ‘Initialize variable’ action and configure it as follows:

6.a. Name: Set to ‘Data

6.b. Type: Select ‘String

6.c. Value: Paste the following value and configure as per the animated guide

{
"Changes":,
"Comments":
}

7. Update the example template as required and upload to a SharePoint document library – Encodian – Blog – Get Tracked Changes Template.docx

8. Add the SharePoint ‘Get file content‘ action and configure to obtain the ‘File Content‘ of the Word template file from the location specified in step #7

9. Add the Encodian ‘Populate Word Document‘ action

9.a. File Content: Select the ‘File Content‘ property provided by the SharePoint ‘Get file content‘ action

9.b. Document Data: Select the ‘Data‘ property provided by the ‘Initialize variable‘ action

10. Add the ‘Send an email (v2)‘ action and configure as required

10.a Attachments Name – 1: Select the ‘Filename‘ property provided by the Encodian ‘Populate Word Document‘ action

10.a Attachments Content – 1: Select the ‘File Content‘ property provided by the Encodian ‘Populate Word Document‘ action

Upon testing your flow, the email sent should contain a word document providing a summary of the tracked changes and comments contained within the document.

Parse Tracked Changes and Send as an Email

Commencing from step #5; 6. Test your flow to verify that tracked changes and comments data is returned by the Encodian Get Tracked Changes action

7. Add a ‘Parse JSON‘ action 7.a. Content: Select the ‘JSON – Tracked Changes‘ property provided by the Encodian Get Tracked Changes action

7.b. Generate the schema following the animated guide below. The sample value should be copied from the ‘JSON – Tracked Changes‘ property value from step #6

8. Add the ‘Send an email (v2)‘ action and configure as per the following animated guide below:

An email will be sent for each change detected within the document. You can perform the same steps to access comments data.

Finally…

We hope this post provides valuable information on obtaining tracked changes and comments from a Microsoft Word document and examples of using the data within Power Automate.

Please share any feedback or comments – all are welcome

Author
Jay Goodison

Managing Director

Back to all blogs

You might also be interested in...