Create an Approval with Microsoft Flow

Updated: Apr 6, 2019

Let's look at how to use Microsoft Flow to automate document approval in a SharePoint Online library (video: https://youtu.be/GuZsdxMU6Kg).


This tutorial uses a library for the Flow, but the same principles apply for a list.


Why set up an approval Flow for your library? In my example, I have a team of training developers who are creating How-To Guides for other employees in the company to view. We want our training managers to approve these guides before they are exposed to the rest of the company.


With an approval library, we can show draft items to approvers and document authors, (in this case the training developers and managers) while hiding drafts from employees with Read access. Once the drafts are approved, we can publish these drafts as Major versions, allowing the employees with read access to see them.


We want to automate the approval process so that when a guide is uploaded to the library, the Training Managers receive an email, asking them to review and approve the guide. Once they approve, we want Flow to automatically publish the guide and send a confirmation to the Training Developer that the guide has been approved and is published for other employees to view.


We will automatically start (or trigger) the Flow by creating file in the library, but you could also use metadata to determine whether the Flow should trigger. More on that later.

Go to Library Settings, then select Versioning Settings

To follow along with this guide:

You need Full Control (or Owner level) permission for the library.


Go to Library Settings, then select Versioning Settings:

  • Enable "Require content approval for submitted items"

  • Enable major and minor versioning



Draft security settings on Versioning Settings page

While you’re there, note the draft security settings. This section determines who can see the file while it is still a draft. I selected the third option, which allows only Approvers and the person who created the file (the author) to see the drafts.


Finally, I highly recommend that you do not require Check Out for the library.



Now that your library is ready, let's go to Microsoft Flow. To access Flow, click the Flow menu at the top of your library and select Create Flow. If you don't see this menu, you can click the Microsoft Applications waffle on the top left, and select Flow. If you don't see Flow here, click the All Apps link. Or, you can type flow.microsoft.com in your browsers address bar, and hit Enter.


STEP 1. Create a new flow. I think the best way to learn to use Flow is to start from a blank Flow. Go to My Flows in the top menu, then select "Create from blank".

You will then see the Flow designer screen.


STEP 2. Add a trigger. This is how we tell our Flow to start. We want our Flow to start when a SharePoint document is created.

  1. Select SharePoint from the Connectors section.

  2. Select "SharePoint - When a file is created (properties only)". Note: If you want to start your flow from a SharePoint list, then select "SharePoint - when an item is created". Another note: If you want to use metadata to start your flow, skip to the bottom of this tutorial page read the Other customizations section. Then come back.

  3. Site address: Use the drop down to select your site. It may take a minute if you haven't connected SharePoint before.

  4. Library name: Use the drop down to select your library.

  5. Folder: Leave blank (unless you only want the Flow to trigger when you upload to a particular folder.

STEP 3. Get manager (optional). Since I want to have the training managers to approve the document, I am going to dynamically (automatically) assign the manager of the developer as the approver. Flow gets this information from Azure Active Directory. If you have a specific person you want to use as an approver, or a mail group, you can skip this step.


  1. Click New Step, then select "Add an action".

  2. Search "Get Manager", then select "Office 365 Users - Get Manager".

  3. Click the User (UPN) field to open the dynamic content menu.

  4. Select "Created by email" to find the manager of the person who created the file.

STEP 4. Set status to Pending. We want the Approval Status in the list to update to reflect the status at each step of the approval process. To do this, we must first set the current status to Pending.

  1. Click New Step, then select "Add an action".

  2. Search "approval", then select "SharePoint - set content approval status".

  3. Fill in site and library information as in step 2 above.

  4. Click the ID field to open the dynamic content menu, and select "ID".

  5. Click the Action field and select "Submit" from the drop-down menu.

  6. Leave the rest blank.

STEP 5. Set the approval settings. We are ready to start the approval.



  1. Click New Step, then select "Add an action".

  2. Search "approval", then select "Approvals - start an approval".

  3. Select an Approval type. Note: "Anyone..." means if you have more than one approver, whoever responds first determines the Approval Status of the item. "Everyone..." means that everyone must Approve in order for the item to be approved. If you only have one approver, it doesn't matter what you pick.

  4. Title is the subject of the approval email your approver will receive. I like to use dynamic content here, like "Please review [Name]" to make the title unique. Feel free to get creative.

  5. Assigned to: this is where your approver email goes. If you got the manager info with me above, search and select Mail from the dynamic content menu. If not, type an email address here. Note: if Mail does not appear, click "See More" in the Get Manager section of the dynamic content menu.

  6. Requestor: Select Created by email from the dynamic content menu.

  7. Details: This is the email the approver will receive. I like to use dynamic content here, too, like "A new document has been created by [Created by]". Formatting is very limited, but get creative with dynamic content.

  8. Item link: Select Link to item from dynamic content menu.

  9. Item link description: Friendly text for the link. Try something like: "Click here to review [Name]".


STEP 6. Set branching logic for Approved vs. Rejected. Now that our approval process is set, we need to tell the Flow what to do in each scenario: if our document is approved, or if it is rejected. To do that, we must first set a Conditional (if, then) statement.

  1. Click New Step, then select "Add a condition".

  2. Click in the Choose a value field, and select "Response" from the dynamic content menu.

  3. Leave "is equal to" as the selection for the second field.

  4. Type "Approve" in the third field (without quotes).


STEP 7. Set approval status for Approved and Rejected.

  1. Under "If yes", click Add an action.

  2. Search "approval", then select "SharePoint - set content approval status".

  3. Fill in site and library information as in above.

  4. Click the ID field to open the dynamic content menu, and select "ID".

  5. Click the Action field and select "Approve" from the drop-down menu.

  6. Click the Comments field and select "Comments" from the dynamic content menu. This updates the document properties with the Comments that the approver provided. Note: when I did this, there were two Comments to select from. I selected the first one and got an error. The second one did not give me an error. I assume this is because Microsoft is tinkering with this feature.

  7. Click the eTag field and select eTag from the dynamic content menu. Tip: use the search in the dynamic content menu to help you find it faster.

  8. Repeat these steps for the "If no" section, except select "Reject" in the Action field.

STEP 8. Send emails for Approved and Rejected.

  1. Under "If yes", click Add an action

  2. Search "Send an email", then select "Office 365 Outlook - Send an email"

  3. Click the To field to open the dynamic content menu and select "Created by email"

  4. Click the Subject field and add an email subject like, "Your document [Name] has been approved!"

  5. Click the Body field and write an email. I like to include the document name, the approver name, and the comments from the dynamic content menu. Feel free to get creative.

  6. Repeat these steps for the "If no" section, except the email should tell the user their document has not been approved.

STEP 9. Save and test. Congratulations! You have created an Approval Flow from scratch! Now go to your library and upload a test document.

Hint: you may not want to test this with your manager set as the approver. Go to the Flow and change the approver to yourself to test. If you want to test to see that the "Get manager" action is working, you can select some information from the Get manager section of the dynamic content menu and insert into the body of one of the emails that your flow is sending.

Other customizations:


Want to use metadata to kick off your Flow?

  1. Add a column to your document library. I made a choice field called "Start Flow". I made the choices "Yes" and "No", setting the default to "No".

  2. In your Flow, you need to use a different trigger at the start: "SharePoint - when a file is created or modified (properties only).

  3. Directly after the trigger, add a condition: Start Flow is equal to Yes.

  4. Under "If no", leave it blank.

  5. Under "If yes", you will need to reset the Start Flow to no. - Use the action "SharePoint - update file properties". - Select your site, library, and file using the Id dynamic content. - Delete any text or data that is pre-populated in the fields. - Set Start Flow to no

  6. Still under the "If yes" block, carry on with the rest of your Flow as above.

475 views1 comment

sme|SharePoint. Made easy.

 

Tampa, FL

856-857-7523

 

  • YouTube - SME
  • LinkedIn - SME
  • Twitter - SME

© 2018 by sme

Send us your feedback or suggest new content topics. We're listening.