Many organisations include a document approval sheet either at the start or end of the document. Using this approach requires the user to manually update the approval table, which is challenging to manage, especially when using an automated approval process to generate an approved version of the document, i.e. you canβt change it once itβs approved! And you canβt complete the approval table (dates, comments) until the approval process is complete.
This Flow will demonstrate how to dynamically generate the approval sheet from Flow approval data and add it to an approved document rendition (PDF).
1. Navigate to the SharePoint document library, which will store and manage the documents sent for approval.
2. Click βFlowβ, and click βCreate a Flow.β
3. Click βShow more.β
4. Select the βComplete a custom action for the selected file.β
5. Click βContinue.β
6. Select the default name of the Flow text and change it to βSubmit for Approval.β
7. Add a SharePoint βGet File Contentβ action to the Flow
8. Configure the βGet File Contentβ action as follows:
8.a – Site Address: This must be set as per the βSite Addressβ value set in the βGet File Propertiesβ action
8.b – File Identifier: Select the βIdentifierβ property returned by the Get File Propertiesβ action
9. Add a βStart and wait for an approvalβ action to the Flow
10. Select the required approval type – this demo uses the βApprove/Reject β Everyone must approveβ approval type
11. Complete the βStart and wait for an approvalβ action configuration as follows:
11.a – Title: Set to βOfficial Document Approval Requestβ or similar
11.b – Assigned ToΒ Enter the users who will be asked to approve the document
11.c – Details: Enter additional detail if needed using markdown
11.d – Item link: Select the βLink to Itemβ property returned by the βGet file propertiesβ action
11.e – Item link description: Select the βFile name with extensionβ property returned by the βGet file propertiesβ action
The Flow approval process is now complete. The next stage is to create the official rendition of the document, obtain the approval data and build the approval sheet that we will insert into the approved PDF document.
12. Add a βInitialize variableβ action
12.a – Name: Set to βApprovalSheetHtmlβ
12.b – Type: Select βStringβ
12.c – Value: Copy and paste the contents of the βApprovalsheetHtml-InitialValue.htmlβ file
13. Add a βConditionβ action
13.a – Choose a value: Select the βOutcomeβ property returned by the βStart and wait for an approvalβ action
13.b – Equation: Set to βdoes not contain.β
13.c – Choose a value: Enter βRejectβ
Inside the βIf Noβ branch, add some relevant handling to inform the requesting user the approval has been rejected (see example below):
14. Add the βSearch and Replace Textβ Encodian action
14.a – File Type: Select βDOCXβ
14.b – Filename: Select the βFile name with extensionβ property returned by the βGet file propertiesβ action
14.c – File Content: Select the βFile Contentβ property returned by the βGet file contentβ action
14.d – Phrases Search Test β 1: Enter [APPROVALDATE]
14.e – Phrases Is Expression β 1: Select βNoβ
14.f – Phrases Replacement Text β 1: Select the βCompletion Dateβ property returned by the βStart and wait for an approvalβ action
15. Add the βConvert to PDFβ Encodian action
15.a – Filename: Select the βFilenameβ property returned by the βSearch and Replace Textβ action
15.b – File Content: Select the βFile Contentβ property returned by the βSearch and Replace Textβ action
15.c – PDF Filename: Select the βFilenameβ property returned by the βSearch and Replace Textβ action. The Encodian action will automatically ensure that the output filename has a PDF extension.
15.d – Click βShow advanced optionsβ
15.e – Remove Markup: Select βYesβ. This ensures that any comments / tracked changes are removed from the resultant PDF document
We have several options/approaches which would work; if the document already contains an βOverview/Title Pageβ, we could:
However, we advise our customers not to include an βOverview/Title Pageβ or βApproval Sheetsβ in the actual documents as these can easily be added dynamically when needed, providing enhanced control and options for adding these types of pages in a document. This is what weβll now doβ¦
16. Add an βAppend to string variableβ action
16.a – Name: Select the βApprovalSheetHtmlβ variable
16.b – Value: Select the βResponses Approver emailβ property returned by the βStart and wait for an approvalβ action
16.c – Value: Enter the following text
<tr>
<td class="TdData utilW100">@{items('Apply_to_each')?['responder']?['displayName']}</td>
<td class="TdData">@{items('Apply_to_each')?['responseDate']}</td>
<td class="TdData">@{items('Apply_to_each')?['comments']}</td>
</tr>
17. Underneath the βApply to eachβ loop, add an βAppend to string variableβ action
17.a – Name: Select the βApprovalSheetHtmlβ variable
17. b – Value: Enter the following text
</table></div></div></body></html>
18. Add an βInsert HTML to PDFβ action
These screenshots of the βInsert HTML to PDFβ action show some configuration options(Page Number, Page Size, Page Orientation), which are currently under deployment and may not reach your region for another 2 to 3 weeks.
18. a – Filename: Select the βFilenameβ property returned by the βConvert to PDFβ action
18. b – File Content: Select the βFile Contentβ property returned by the βConvert to PDFβ action
18.c – HTML Data: Select the βApprovalSheetHtmlβ variable
18.d – HTML Insert Location: Select βPrependβ
If you cannot see the βHTML Insert Locationβ your region has not yet received the pending updates, click βShow advanced options to update the βHTML Insert Locationβ option
The document has now added the approval sheet containing document information and approval details. You may now wish to add a document title sheet dynamically.
This is already a lengthy post, so weβve just included a basic example for dynamically creating a document title sheet as a taster!
A Word template is retrieved from SharePoint, the Encodian βSearch and Replaceβ action is used to replace the placeholder text with the document title and approval date, and a PDF rendition is created and merged with the actual PDF document that already contains the approval sheet.
Add the resulting approved document to the required location. In this example, weβll add the file to the originating location.
19. Add a βCreate Fileβ SharePoint action
19.a – Site Address: This must be set as per the βSite Addressβ value set in the βGet File Propertiesβ action
19.b – Folder Path: Select the βFolder Pathβ property returned by the βGet file propertiesβ action
19.c – Filename: Select the βFilenameβ property returned by the βInsert HTML to PDFβ action
19.d – File Content: Select the βFile Contentβ property returned by the βInsert HTML to PDFβ action
Before you test, we advise reviewing the following blog post, which outlines how to share your Flow with users correctly to ensure connections are shared with the correct configuration to negate the need for users to enter unnecessary connector authentication information such as API Keys:
The βrun only usersβ configuration for this demonstration flow has been set to the following configuration:
20. Go to SharePoint and start the Flow
21. Click βContinue.β
22. Complete the approval requests (Approve!)
23. The approved PDF file with the embedded approval sheet should have been created
Although this post has focussed on creating and manipulating a PDF document, this could also be achieved with a Word document (Docx) using the βHTML to Wordβ and βMerge Word Documentsβ actions to replace their PDF equivalents.
We hope youβve found this guide useful, and as ever, please share any feedback or comments. All are welcome!
UPDATE: Weβre excited to announce some significant updates to Flowr for Power Automate! As of October 2024, weβve improved by updating action names and splitting Flowrβs central Power Automate connector into nine specialized connectors. These changes will make your workflow faster, smoother, and more efficient. The new action names are more precise and intuitive, saving you time, while the focused connectors enhance performance and flexibility. This update also helps future-proof the platform for even more powerful features. Check out our updated action names blog.
Managing Director