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
An essential part of the solution is the ability to execute Flow actions with another account (a service account) than the account used by the person starting the Flow. This allows someone to make changes to SharePoint objects where they normally do not have access to. The service account must have the elevated permission. As a solution designer you of course have to make sure this does not result in security issues.
For this solution I used one service account (workflow@…), also called the workflow account. The name of the account is important because it will be shown at the columns “Created By” and “Modified By” at several places. Using a long name will make those columns unnecessary wide. Using a strange name will make people wonder who made the change.
Below is a summary of the actions which need to be executed with elevated privileges:
- Copying a file and metadata to the document library “Requests” by the person starting the approval process (starting the approval request Flow).
- Creating a task for a requester by the person starting the approval process.
- Updating metadata of files in the preparation document libraries by an approver.
- Updating metadata of files in the document library “Requests” by an approver.
- Creating a task for a requester by a requester.
Below are the configuration steps executed to create a Flow with actions run with a service account:
- Go to a document library.
- Add a Flow via the option “Complete a custom action for the selected item”. One must scroll down with the “Show more” link to see that option.
- Create the Flow. In this solution I used actions of the connectors “SharePoint” and “Office 365 Outlook”.
- A Flow of this type has a “MANAGE RUN-ONLY USERS” section in the configuration page. A screenshot is given below. Choose “Add another user”.
- A panel with 2 tabs is shown. Go to the tab “SharePoint”.
- Here you can configure who can run the Flow and which account to use for the connections. I this specific case, I added the preparation document library “Projects” and the workflow account to use for both connections. A screenshot is given below.
Important to know
- Someone must have “Edit” permissions on the preparation document library to start the Flow. “Contribute” permissions is not sufficient.
- It is possible to add multiple connections of the same type (like “SharePoint”). These connections can be individually configured. This solution has only one connection per type (“SharePoint” and “Office 365 Outlook”).