This post is part of a series where we examine the advantages and disadvantages of a document approval process, and then build an example automated solution with SharePoint and PowerAutomate.
Posts in this series:
- Should you automate your document approval process?
- Building a basic document approvals automation with SharePoint and PowerAutomate
Create the new PowerAutomate Flow and its Trigger
As user, Lynne, navigate to the PowerAutomate web application. This can be reached by visiting https://make.powerautomate.com.
Select the Create option from the navigation menu to begin creating the new flow.
A wizard is shown where you can enter the name of the new flow and choose its trigger.
Unfortunately the trigger we need is not selectable from the wizard, so we’ll Skip straight to the flow canvas and manually add the needed trigger there.
When viewing the flow’s canvas, the first things we should set is the flow’s name. Here we have named the flow, D022 Request finance document approval.
To set a trigger for the flow, we click the Add a trigger element, search for for a selected file and then chose the SharePoint: For a selected file trigger.
Notice in the above screenshot that the triggers are groups by Connector, and that we selected the For a selected file trigger from the SharePoint connector.
Triggers and Actions that interact with other systems are defined as part of a Connector that handles that type of system.
Connectors often make use of Connections to handle authorisation to access those systems. In the screenshot below, we are prompted to create (and authorise) a new connection to SharePoint for use by the SharePoint connector.
By clicking on the Sign in button the current user, Lynne, will be able to authorise a connection to SharePoint on her behalf for use by the connector in the flow. All SharePoint interactions carried out by the flow will then have the same permissions to SharePoint sites as Lynne.
If a SharePoint connection already exists for the current user, it will be reused by any new triggers or actions from the SharePoint connector added to PowerAutomate flows.
The side-panel then shows the parameters that can be configured for the For a selected file trigger.
We need to configure the Site Address with the Finance Team Site and the Library Name with the team’s default document library.
Clicking in the Site Address parameter, a drop-down selection is shown with a list of SharePoint sites known the current user (Lynne). However the new Finance Team Site is missing from the list.
When the desired site is missing, we can select Enter custom value and type/paste in the web address (URL) of the site. In this example the site address is https://watconsdev.sharepoint.com/sites/D022DraftFinanceDocuments.
With the site address entered, we can then select Documents for the Library Name parameter.
So far we have created a new PowerAutomate Flow configured to trigger for a selected file on a SharePoint site and document library specified in the trigger’s parameters.
The purpose of this trigger is to detect a member of the Finance authoring group selecting a document in SharePoint and then launching this flow to request a document is reviewed and published.
Send an email to the document approver
To add an action to send an email to the document approver, click on the + icon below the trigger and then choose Add an action from the pop-up menu.
On the side panel, enter email with options into the search box and then select the Send email with options action from the Office 365 Outlook connector.
Similar to above when we added the trigger from the SharePoint connector to the flow, we are prompted to now authorise a connection for use by the Outlook 365 connector.
This connection will allow the flow to interact with Outlook 365 on Lynne’s behalf.
For this flow dealing with documents from the Finance authoring group, the approver will be Alex. We therefore need to set Alex’s email address in the To parameter for the action.
We also want to set parameters for the Selection Text, Body and HTML usage for the sent email. To do this we need to enable display of these parameters from the Advanced parameters drop-down selection box.
In the email to the approver, there will be a some text displayed above the Approve/Reject choices. This text is configured using the Selection Text.
We want the selection text to display:
Document approval request: <name of document>
The above text is a combination of static content (Document approval request: ) and dynamic content (<name of document>).
To enter the combination of static and dynamic context, click the Selection Text parameter text box and type the following static content:
Document approval request:[space]
To then choose the dynamic document name (i.e. the selected file name from the trigger), either click the lightning icon or type forward-slash (/) and select Insert dynamic content from the pop-up menu.
A dynamic content selection pop-up is shown from which an output from an earlier trigger or action can be selected.
We use the filter to show only those dynamic content items that include name. We then choose the fileName content item which is output from the For a selected file trigger.
This dynamic content item will then be substituted when the flow runs with the name of the document that was used to trigger the flow’s execution.
The approver needs an easy way to find the document they are being asked to review. Although we give them the name of the document, we should also provide them with a link directly to the document.
The body of the email should look similar to:
Please approve the following document so that it can be published.
Document: <filename with link>
Approving this document will trigger its automatic publication to the central published documents repository.
To (nicely) include links, we’ll want to use HTML for the body of the message. In the screenshot below notice that we have using paragraph (<p></p>) tags to improve the formatting of the email when viewed in Outlook.
To set the URL of the document to be reviewed on the link in the email, we place the text cursor between the pair of double-quotes (“) that follow href=. We then type forward-slash and select dynamic content before choosing the itemUrl output from the trigger.
Next we need to set the file name of the file as part of the HTML link in the email body.
Place the text cursor between the > and < symbols shown in the screenshot below, type a forward-slash and then select the fileName from the available dynamic content.
Since we have used HTML in the body of the outgoing email, it makes sense to ONLY use the HTML version of the message.
The last two parameters we need to configure the for Send email with options action are the Subject and User Options parameters.
Here we set the Subject with the same value as that used for the Selection Text parameter above.
The User Options parameter is a list of options that will appear as buttons in the email. The list of options are separated by commas. We set this parameter to Approve,Reject to specify the two outcomes from an approver’s review of a document.
At this stage we now have a flow consisting of a trigger and a single action. This is the minimum needed to save, so clicking on the Save option is recommended.
Note that once the flow has saved, PowerAutomate seems to rename the trigger to manual. This appears to be a bug (2024-09-20) and may be fixed in future updates to PowerAutomate. The flow’s behaviour is unaffected by renaming the trigger.