Showing results for 
Search instead for 
Did you mean: 

Guide: Redact documents in Microsoft Flow

We’ve been having lots of conversations recently with customers, community members and Microsoft about providing secure access to information and documents contained within Office 365 and how to secure documents at REST where there is a requirement to distribute outside of an organisation’s Office 365 tenant.

There are already well-documented features within the Microsoft Office client applications which enable sections / resources to be protected, however what happens where you simply want to redact the content, and what happens where you want to redact the content across multiple different file formats including Microsoft Office File Formats

Redacting documents with Microsoft Flow

Encodian have recently released the ‘Redact PDF‘ Flow action, which well… redacts content in PDF documents! But hang on… this only works for PDF documents? Yes, that is 100% correct and with good reason. Our research showed that in 99.99% of use cases where redaction was required, it also required the document to be shared in a consistent, secure and immutable format (PDF), regardless of source file format.

By combining Microsoft Flow’s native or Encodian’s advanced PDF conversion actions, we’re able to provide document redaction for 70+ different file formats, allowing redaction rules to be easily applied to documents

Example Usage: Redact document content within matching tags

The ‘Redact PDF‘ action allows a user to specify one or more rules, that locate content based on a free text search or a regex query. For example, you could specify to redact ‘Please redact me‘ where all instances of that text found within the document would be redacted. You could also utilise a regex for complex queries to find matching content before redacting.

The following steps outline how to setup a new Flow which locates sections within a document based on start and end tags using a regex query.

1. Create a new Flow from a blank template


2. Enter a name for the flow, select the ‘When a file is created or modified (properties only)‘ trigger action, click ‘Create


3. Update the SharePoint trigger actions with the selected site, library and folder location

3a: Site Address: <SharePoint Web Url>

3b: Library Name: <Library Name>

3c: Folder: (Optional) <Folder Name


4. Add a ‘Condition‘ action to check whether the updated document has been approved.


5. To check whether a document has been approved a choice field has been added to the SharePoint document library, we simply need to check whether the ‘Status‘ fields value is equal to ‘Approved‘, of course you can apply your own logic here as needed. Set the condition action as follows:

5a. Set the condition value to the ‘Status Value‘ from the SharePoint trigger action


5b. Set the operator to ‘is equal to

5c. Set the equation value to ‘Approved


6. Within the ‘If yes‘ branch, add a SharePoint ‘Get File Contents‘ action


6a. Site Address: As per the value to set in step 3a

6b. File Identifier: Select the ‘Identifier‘ value from the SharePoint trigger action


7. Next add a Encodian ‘Convert to PDF‘ action


7a. Filename: Select the ‘File name with extension‘ field from the SharePoint trigger action


7b. File Content: Select the ‘File Content‘ field from the ‘Get File Content‘ action


7c. PDF Filename: Select the ‘ File name with extension ‘ field from the SharePoint trigger action

Note: The Encodian connector will automatically change the file extension to PDF.


8. Next add a Encodian ‘Redact PDF‘ action

8a. Filename: Select the ‘Filename‘ value from the ‘Convert to PDF‘ action


8b. File Content: Select the ‘File Content‘ value from the ‘Convert to PDF‘ action


8c. Redactions Expression – 1: Add the following regex expression ‘ SSS\\[(?s)(.*?)\\]FFF 

This expression will locate all text which appears between the text starting ‘SSS‘ and finishing ‘FFF‘, noting that any regular expression can be used. We recommend using the site for expression creation and testing.

8d. Redactions Redaction Colour – 1: Add your chosen redaction HTML colour code


9. Next add a SharePoint ‘Create file‘ action


9a. Site Address: As per the value to set in step 3a

9b. Folder Path: Enter the chosen destination library / folder


9c. File Name: Select the ‘Filename‘ value from the ‘Redact PDF‘ action


9d. File Content: Select the ‘File Content‘ value from the ‘Redact PDF‘ action


10. The flow is now complete and ready for testing, your completed Flow should look similar to:


11. Click ‘Test‘, click ‘I’ll perform the trigger action‘, click ‘Save & Test


12. Update the target SharePoint file and set the required value to assure the document will be processed according to the business logic you have configured. In this example, I will update the ‘Status‘ field to equal ‘Approved‘ to trigger the flow.

13. Your new Flow should successfully execute


The resulting document should have been redacted according to the configuration supplied.


Thanks for reading!

About the Author
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Blog site: MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. You can find me on LinkedIn: and twitter I also write at, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 15 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – Youtube channel -