On 2018-09-18 I gave a presentation about the business solution “Investment requests” I created with: SharePoint Online (Modern team site), PnP PowerShell, Flow and PowerApps. The 45 minutes were over before I knew it. Several topics were not, or in lesser detail, presented. I therefor decided to start a blog post series specially for this.
The blog post series has the following topics:
- Executing Flow actions with service account permissions
- And something more
At several moments, an email is sent:
- to the person starting the approval process.
- to an approver.
When creating a solution, it is very much preferred to sent emails from a fixed email address. Using a shared mailbox to sent email is possible for this solution! When an employee starts the approval process, the “Office 365 Outlook” action is executed by the workflow account (See part 2 of this blog post series). The workflow account has permissions on the shared mailbox to sent emails. The Flow on the task list was created by the workflow account. When a new item was added, or an existing one was updated, the actions run as the workflow account, again having access to the shared mailbox to sent email.
The shared mailbox has the same name as the solution (“Investment requests”) and it was proposed to work this way for all solutions (processes in SharePoint Online). This way, approvers can easily see that a task has been created for them by this process. They can even make Outlook rules.
Working with email templates which are stored outside a Flow has as advantage that corporate styling updates can be implemented without having to change a Flow. This is often regarded as a less impactful change than changing a Flow. Email templates also support: Create once, use often.
For this solution, I created a SharePoint list called “Settings” containing several columns among a “Multiple lines of text” column. This field contains the email template. Every email template has a specific value in the column “Title”. In total 7 different email templates were created:
- Email to the initiator when fields are empty.
- Email to the initiator when a wrong (sub)category is chosen.
- Email to the initiator when a file with that name already exists in the document library “Requests”.
- Email to the initiator when the approval request Flow is successfully processed.
- Email to an approver.
- Email to the initiator when the investment request is approved.
- Email to the initiator when the investment request is declined.
A few email templates have one or two variables. I choose a a double curly braces setup for variabels. A screenshot is show below.
Because this email was sent as HTML email, a few HTML elements were added to create some spacing.
In the created Flows, an email is sent with the following actions:
- SharePoint – Get item
- Set variable
- Set variable
- Office 365 Outlook > Send an email from a shared mailbox
The “Set variable” actions are only used when variables need to be replaced. A screenshot is given below.
This specific case was about sending an email when an approval request was declined. Two variables were used: The unique ID of the request and the comment of the approver who declined. When an approver choses “Decline” (PowerApp SharePoint form), a comment has to be filled in.
A goal was to keep the amount of emails to a minimum. This can be seen as a best practice for all solutions.
An approver gets an email containing two links:
- Link to the document in the document library “Requests”.
- Link to the task in edit mode.
This way, the approver does not have to go to SharePoint to check if a task is available for him/her. The task is in “edit mode” to minimize the number of clicks for an approver.