Get Tracked Changes from a Microsoft Word Document with Power Automate

Get Tracked Changes for Word with Power Automate

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 🙂

Secure Microsoft Word Documents with Power Automate

How to Secure Microsoft Word Documents with Power Automate

We recently released the ‘Secure Word Document’ action which can be used to secure (also known as protect) a Microsoft Document covering all the typical file formats (DOCX, DOC, DOTX, DOT, DOCM, DOTM and RTF). The action provides the following options for securing / protecting the Word document controlled by the ‘Protection Type‘ option:

  • AllowComments – Users are permitted to add / modify comments only
  • AllowFormFields – Users can enter data into form fields only
  • AllowRevisions – Users can add revision marks only
  • ReadOnly – Users are blocked from applying any modifications to the file
  • NoProtection – The document is not protected

For this post we’ll provide two very basic examples for using the ‘Secure Word Document’ action to add protection and remove protection from the Word document. **We’ve also included a bonus video showing how you can quickly use Encodian Trigr to deploy the flow used for these examples to your entire SharePoint environment!

Protect a Microsoft Word Document with Power Automate

For this basic example we’re simply going to create a manually invoked Power Automate Flow, secure the selected Word Document and save to OneDrive, simple!

1. Navigate to https://make.powerautomate.com

2. Click ‘New flow‘ > ‘Instant cloud flow

3. Complete the form:

3.a Flow name: Enter a relevant name for your flow

3.b Trigger: Select the ‘Manually trigger a flow‘ trigger action

3.c Click ‘Create

4. Select the ‘Manually trigger a flow‘ trigger action, click ‘Add an input

5. Select ‘File

6.Underneath the ‘Manually trigger a flow‘ trigger action, add the Encodian ‘Secure Word Document’ action:

6.a. Filename: Manually enter a value, in a real world scenario you would obtain the filename from the file properties.

6.b. File Content: Select the ‘File Content‘ property provided by the ‘Manually trigger a flow‘ trigger action

6.c. Password: Enter the password which will be used to protect and remove protection from the document

6.d. Protection Type: Select the ‘ReadOnly‘ option

7. Underneath the Encodian ‘Secure Word Document’ action, add the OneDrive ‘Create File‘ action

7.a. Folder Path: Select the location within OneDrive to save the protected Word document

7.b. File Name: Select the ‘Filename‘ property provided by the Encodian ‘Secure Word Document’ action

7.c. File Content: Select the ‘File Content’ property provided by the Encodian ‘Secure Word Document’ action

That’s it all done! The Power Automate flow will now secure the selected document and save you the configured OneDrive location! Your flow should look similar to the following:

After executing the flow, you will see the secured Microsoft word document added to your OneDrive:

And upon opening the file you’ll be able to verify the protection level applied to the document:

Remove protection from a Microsoft Word Document with Power Automate

Following on from adding protection (securing) a Microsoft Word Document, this section outlines how to remove protection.

1. Configure your flow as per the ‘Protect a Microsoft Word Document with Power Automate‘  of this article

2. Update the Encodian ‘Secure Word Document’ action as follows: 2.a. Protection Type: Select the ‘NoProtection‘ option

That’s it :)! The flow has now been configured to remove protection from the selection Microsoft Word Document!

Deploy the Power Automate Flow to all SharePoint Sites and Document Libraries

What if you wanted to deploy the Flow you have created to secure / protect Microsoft Word documents to all SharePoint libraries? This can be very quickly achieved using Encodian Trigr, checkout the following video guide 🙂

Finally…

We hope this post provides a helpful example of how you secure Microsoft Word documents using the Encodian ‘Secure Word Document’ action and Microsoft Power Automate.

Please share any feedback or comments – all are welcome 🙂

Digitally Sign a PDF Document with Power Automate

We’re pleased to announce a new Power Automate action, ‘Sign PDF‘ for Encodian ‘Flowr‘, which provides the capability to digitally sign a PDF document in Power Automate with two different options. The ‘Standard‘ option uses Encodian’s ‘Adobe Approved Trust List‘ certificate. Thus, a signed document will appear as an approved signature with long-term validation enabled (the signature image is optional).

The ‘Custom‘ option allows you to provide a custom certificate in PFX format, which is used to sign the document. The validity of the signature will depend on the certificate provided

Sign a PDF Document after approval in Power Automate

To provide an example of using the ‘Sign PDF‘ action, we’ll cover a very common scenario; after a document has been approved via a Power Automate approval process, we’ll create a signed PDF rendition of the selected document.

Consider the following simple flow associated with a specific SharePoint library. The user can select a file in SharePoint and submit it for approval to the specified ‘Approver’. The approval outcome is then emailed to the user who started the flow… simple!

We’re now going to extend this flow to convert the selected document to PDF and add a digital signature using the ‘Sign PDF‘ action before adding the signed PDF document to the SharePoint library!

1. Within the ‘If yes‘ branch, add the SharePoint ‘Get File Content‘ action

1.a Site Address: Set as per the ‘Site Address‘ value for the ‘For a selected file‘ trigger actions ‘Site Address‘ value

1.b. File identifier: Select the ‘Identifier‘ property provided by the ‘Get file properties‘ action

2. Move the ‘Send and email (V2) – Approved‘ action beneath the SharePoint ‘Get File Content‘ action.

3. Underneath the SharePoint ‘Get File Content‘ action, add the Encodian ‘Convert to PDF‘ action

3.a. Filename: Select the ‘File name with extension‘ property provided by the ‘Get file properties‘ action

3.b. File Content: Select the ‘File Content‘ property provided by the ‘Get file content‘ action

3.c. PDF Filename: Select the ‘File name with extension‘ property provided by the ‘Get file properties‘ action

We’re now going to add the ‘Sign PDF‘ action by selecting the ‘Standard‘ certificate type. This uses Encodian’s ‘Adobe Approved Trust List‘ certificate. Thus a signed document will appear as an approved signature with long-term validation enabled.

The ‘Sign PDF‘ action advanced options allow you to configure whether an image signature should be visible, also providing the opportunity to provide your signature image. For example, you could pass an image generated from a PowerApp ‘Pen input’ control and use this as the signature image!

4. Underneath the SharePoint ‘Convert to PDF‘ action, add the Encodian ‘Sign PDF‘ action

4.a. Certificate Type: Select ‘Standard

4.b. File Content: Select the ‘File Content‘ property provided by the ‘Convert to PDF‘ action

5. Underneath the Encodian ‘Sign PDF‘ action, add the SharePoint ‘Create file‘ action

5.a. Site Address: Set as per the ‘Site Address‘ value for the ‘For a selected file‘ trigger actions ‘Site Address‘ value

5.b. Folder Path: Select the ‘Folder path‘ property provided by the ‘Get file properties‘ action

5.c. File Name: Select the ‘Filename‘ property provided by the Encodian ‘Sign PDF‘ action

5.d. File Content: Select the ‘File Content’ property provided by the Encodian ‘Sign PDF‘ action

That’s it all done! The Power Automate flow will now create a digitally signed PDF from the approved document! Your revised flow should look similar to the following:

After testing the flow, you should see the signed PDF document added to your SharePoint library:

Open the PDF within Adobe Acrobat (or equivalent) to view the signature:

Deploy your flow to all SharePoint Libraries

Don’t forget that you could deploy this flow to all SharePoint sites and libraries using Encodian ‘Trigr‘. For guidance on how to do this, please check out Publish an existing SharePoint Power Automate Flow to Multiple Libraries

Here is an example of the flow configuration, updated to support all SharePoint libraries:

Finally…

We hope this post provides a helpful example of digitally signing a PDF document using the Encodian ‘Sign PDF‘ action and Microsoft Power Automate.

Please share any feedback or comments – all are welcome 🙂

Insert HTML into a Word Document with Power Automate

An ever-present question we’re seeing via our support service and from within the Microsoft Power Automate community: How can I insert HTML data into a Microsoft Word Document using Power Automate? It’s pretty simple to use our ‘Populate Word Document‘ action, and this post will provide an example of how to use this feature.

If you’re new to the ‘Populate Word Document‘ action, we recommend reviewing this post’s ‘Populate Word Basic Principles‘ section: Populate a Word or PDF Document using Power Automate V2.

Further detailed guidance can be obtained on our support portal: Populate Word Document – Inserting HTML.

Add SharePoint-rich text data (HTML) to a Word Document

I’m not going to use a real-world scenario as such for this example, as we’ll focus on the mechanics of adding HTML data into a word document. For this basic scenario, I will obtain HTML data from a SharePoint list item column which contains rich text data, as this is an everyday use case. For this demo, I have configured a word document as follows:

I have created a SharePoint list item which contains the following data:

And I have made the following super simple flow:

I’m passing in the template word file when the flow is manually triggered. We then retrieve the item from SharePoint. The file is passed to the ‘Populate Word Document‘ action along with the value of the ‘HTML Example‘ column bounded by a basic JSON structure. We then add the populated document to Onedrive… simple! 🙂

When I execute the flow, it fails with the following error: A error occurred parsing the JSON document provided: After parsing a value, an unexpected character was encountered. This is because the ‘Document Data‘ property has received invalid JSON caused by unescaped double quotes.

HTML markup contains lots of double quotes (also known as speech marks), and if you want to insert HTML data into JSON, then you must escape the double quotes, which is luckily relatively simple and documented in detail here: Escape double quotes in JSON using Power Automate

To resolve this issue I need to wrap the ‘HTML Example‘ property value in the following expression: replace(<dynamicDataHere>,'”‘,’\”‘)

Now I can re-execute the flow successfully:

And validate that the HTML data has been added to the document correctly:

Finally…

We hope this post provides a helpful example of how to pass HTML data obtained from a PowerApp, website, SharePoint item, etc. and then add the HTML data into a Word document (which could also be converted to PDF!)

Please share any feedback or comments – all are welcome 🙂

Populate a Word or PDF Document using Power Automate V2

Want to know how to populate a Word or PDF document using Power Automate? Well, you’re in the right place!

Back in May 2020, we posted to show how you can dynamically add data to a PDF or Word document using the following Encodian actions:

Now, these actions still provide viable options for adding data to PDF / Word documents. Still, there is a fourth option which we’d suggest as the optimal solution for generating documents and populating them with data. The ‘Populate Word Document‘ action provides a powerful solution which handles conditional logic, repeating sections, table data, lists, HTML, document insertion, charts and much more! Please refer to the syntax documentation for further details: Template Syntax for Populate Word Document. We’ve previously posted example solutions which use the ‘Populate Word Document‘ action, which is well worth reviewing:

Populate Word Basic Principles

The ‘Populate Word Document‘ action requires two elements

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

The Microsoft word document should be configured with tokens which will be replaced at runtime with the JSON data provided. An example of a token:

An example of a corresponding JSON data structure:

{
"companyName":"Encodian"    
}

Note the name of the JSON node matches the value of the token: companyName

Here is a very simple Flow which will populate the manually provided document and save the output to OneDrive:

The resulting document:

Create a document using data from a PowerApp

Consider this common scenario; We have a PowerApp which collates data for a business purpose, and once the data is collated, we need to create a document rendition of that data. I have set up a very simple PowerApp for conducting an ‘Employee Review’ to demonstrate this. I will pass the data to Power Automate to create a document representing the data captured during the review.

This is the super simple PowerApp, noting I have just added controls to a screen as opposed to using a form:

Follow these simple steps to update the PowerApp to pass data to a Power Automate flow.

1. Click ‘Power Automate‘ > ‘Create new flow.

 

2. Click ‘Create from blank.

3. Set a name for your Flow

4. Add the SharePoint ‘Get File Content‘ action or related action to obtain the ‘File Content’ of the Word template file.

The word template for this demo has been configured as follows:

5. Add the Encodian ‘Populate Word Document‘ action

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

5.b. Document Data: Select ‘Ask in PowerApps

We’ll configure the PowerApp to provide data as a JSON string. However, the pen input control within the example PowerApp will give the image as a dataUri value and not a base64 string.

The Encodian action only expects a base64 value; therefore, we can add this simple replace() expression to omit the unwanted dataUri details.

Additionally, the PowerApp will return the data as an array, but we only need access to a single property (the JSON string), so therefor we need to use the following complete expression configuration to replace the unwanted data values and obtain the first item within the array:  first(json(replace(<PowerAppProperty>,’data:image/png;base64,’,”)))

Update the flow as follows:

We now need to do something with the generated file. For this demo, we’ll save it to SharePoint. You may wish to parse the JSON value provided by PowerApp so that you can use this data within the flow. I’ve just hard-coded the filename value for demo purposes.

6. Add a SharePoint ‘Create file‘ action

6.a. Site Address: Set to the value of the SharePoint site, which contains the target document library

6.b. Folder Path: Set to the value of the target SharePoint folder

6.c. File Name: Enter the required value

6.d. File Content: Select the ‘File Content‘ property from the ‘Populate Word‘ action

7. Save and close the flow

8. Within the PowerApp, select your submit button, and click ‘Advanced.

9. Within the ‘OnSelect’ property, add the following configuration updating as required for your application:

ClearCollect(colData, 
{
employee: inpEmployee.Text,
employeeNumber: inpEmployeeNumber.Text,
role: inpRole.Text,
manager: inpMngrName.Text,
department: inpDepartment.Text,
managerRole: inpMngrRole.Text,
reviewDate: inpReviewDate.SelectedDate,
comments: inpComments.Text,
signature: inpSigned.Image
}
);

 

This configuration collates data within the form into a collection so we can pass it to the Power Automate flow.

10. Underneath the previously added configuration, append the following: ‘<autoSelect>‘.Run(JSON(colData, IncludeBinaryData));

11. Your PowerApp is ready for testing. On clicking the ‘Submit’ button, data will be sent to the Power Automate flow.

12. The Power Automate flow will be invoked, and the JSON data will be passed to the Encodian action

13. The document will be available from the configured location.

If a PDF rendition is required, update your flow to use the Encodian ‘Convert Word‘ action as follows:

Finally…

We hope this post provides valuable information on how to build documents passing dynamic data, specifically how to do this using data collated via a PowerApp.

Please share any feedback or comments – all are welcome 🙂

Publish an existing SharePoint Power Automate Flow to Multiple Libraries

make power automate flow available across sharepoint

So, you have created a Power Automate flow linked to a document library in SharePoint Online, and you now need to make this flow available across multiple SharePoint libraries.

We’ve all been here, and the options are limited. When you create a Power Automate flow linked to a document library in SharePoint Online, it is hard-coded to that document library. You’ll need to create a replicate flow for all other libraries you would like to use the flow… possible for a few libraries but not at scale, and it’s always a bad solution to create replicas!

For this post, we’re going to show you have you take your existing flow and re-configure it to be instantly available across all SharePoint Online document libraries using Encodian Trigr!

Consider this simple ‘Approval’ automation which can be launched from a single SharePoint document library:

This ‘Submit for Approval’ automation is only available on this document library and is configured as follows:

As depicted, the simple limitation is that the SharePoint actions are hard-coded to a specific site and document library! Let’s fix this!

Migrate an existing flow to Encodian Trigr

We will update this flow to use Encodian Trigr to make it available across all SharePoint Online document libraries.

If you haven’t already, you’ll need to set up Encodian Trigr takes five or so minutes to do, please check out this guide: Deploy a Power Automate Flow to multiple SharePoint libraries or lists

If you need to sign up for a trial, please visit: Sign up for a Trigr Trial

Choose your Power Automate trigger

1. Delete the ‘For a selected file’ trigger action from your flow

2. Enter ‘Encodian’ within the search box, select the ‘When a user runs a Trigr’ trigger action

3. Set the ‘Title’ and ‘Description’ fields

4. We now need to update the values applied to the SharePoint ‘Get File Properties’ action

4.a. Site Address: Select the ‘Site Address’ property provided by the ‘When a user runs a Trigr’ trigger action

4.b. Library Name: Select the ‘Library/List Name’ property provided by the ‘When a user runs a Trigr’ trigger action

4.c. Id: Select the ‘Item’ property provided by the ‘When a user runs a Trigr’ trigger action

5. Save the changes to your flow

The flow configuration update is complete! We now need to configure Encodian Trigr to make this flow available across all document libraries within our SharePoint Online tenant.

6. Navigate to your Encodian Account Portal

7. Login using the credentials supplied in the ‘Your Encodian Trigr Trial is ready!’ email

8. Select ‘Encodian Trigr’ > ‘Configuration’

9. Click ‘Add Action.

10. On the ‘Add Action’ form

10.a. Select your Microsoft Flow.

10.b. Update the ‘Title’ and ‘Description’ fields if required

10.c. Add a ‘Run Message’ which will be displayed to the user after the flow has been triggered

10.d. Del-select the ‘Lists’ checkbox in the ‘Appear in’ section. Our flow is document library-specific, so we do not want the action to appear within lists.

10.e. Click ‘Create.

11. Your ‘Action’ has now been created and will be available across all SharePoint sites

The action can be found via the Encodian Trigr App as below:

Final thoughts…

Hopefully, this post provides a detailed guide on how you can migrate your current Power Automate flows from a single document library, making them available across your entire SharePoint Online tenant with Encodian’ Trigr.’

We hope you’ve found this guide useful; please share any feedback or comments. All are welcome!