How to Use Microsoft Flow to Approve and Move Files
What is Microsoft Flow?
“Microsoft Flow is a cloud-based service that makes it practical and simple for line-of-business users to build workflows that automate time-consuming business tasks and processes across applications and services.”
In a recent post titled “How to Start Using Microsoft Flow in 10 Steps,” I explained Microsoft Flow templates and connectors. Today, we’ll look at how you can use Flow to run approvals on documents and then move them to other folders.
What is Your Desired Outcome?
First, it’s important to understand what you want to achieve. It helps to write it down to identify any steps you might have missed:
- User loads new word document in the Submitted Channel (via conversation or straight in the File Library).
- Flow should notify first reviewer to review the blog.
- Once reviewed, Flow moves the document from Submitted to Reviewed (Flow deletes the old document and creates a new one).
- When document is “loaded” in the Reviewed folder, notify the final approver to approve the document.
- Once approved, move (delete and recreate) the document to the Approved folder.
Negative testing is important, so you need to consider what happens if someone rejects the document.
- If a document is rejected at any stage, Flow should move it to the Rejected folder.
- Setup alerts for people deleting content—this will notify you immediately.
What are the Requirements?
I would need an environment where I have folders and where users can upload documents. For this example, I’ve used Microsoft Teams (as you know the document library sits on SharePoint).
In the Team, I created a channel for Submitted, Reviewed, Approved, and Rejected:
These channels create folders, which can be seen in the SharePoint Document Library:
Create the Microsoft Flow
Now that the environment is ready, we can create the Flow.
Navigate to https://flow.microsoft.com/ and login with your Office 365 credentials. Then, go to Templates and search for “If you Approve a new file in SharePoint, move it to a different folder.”
You’ll notice there’s a similar template that will even send an SMS:
When you’re signed in with your Office 365 account, your credentials for SharePoint and approvals should be authenticated already. Click on Continue:
Remember to rename your Flow. It might not mean much when you create your first couple of Flows, but as soon as you have hundreds, it will be difficult to differentiate them.
When a file is created:
Select your Team site or use custom value to paste the URL to your site. Here, you will select Shared Documents > Blogs Submitted:
Start an approval:
Under the “Start an Approval” step you need to give a title, the name of the assigned to (reviewer), as well as details for the approval mail:
Based on above approval status, this is where you would define what needs to happen to the file.
If Approved, then create a file in the Reviewed Folder.
Now Flow will delete the file in the Submitted Folder:
Move file if rejected:
This is where I build an extra step in on this template. I also want the flow to move the file to the Rejected folder if the status is Rejected. Under “No,” add an action.
Search for SharePoint Create File. Enter the site address and folder path to the Blogs Rejected. I’ve selected current file name and content type.
Now, add another action and search for SharePoint Delete File. Enter the site address and choose file identifier for current file.
Create the Flow and click Done. The flow will now be ready to rest for the Submitted to Review stage. We need to create another Flow to cover the step from Reviewed to Approved.
Follow the exact steps above, but instead choose the Reviewed and Approved folders:
When a file is created in the Reviewed folder, send an approval email to “X”:
If approved, create a file in the Approved folder, then delete the current file (in the Reviewed folder):
Add the extra Action for when a file is Rejected. Create File in SharePoint in Blogs Rejected folder, then delete the current file. Create & Save the Flow and then click Done:
Your Flows are now created and ready to go!
There’s normally a couple of minutes between runs, so that gives you time to load a test file in the Submitted Folder:
I’ve loaded a file in the Blogs Submitted Channel where I attached it to a conversation:
Here, you’ll see that Microsoft Teams automatically stores the document in the “Submitted Folder” in the Files Tab:
Now that a file is loaded in the Submitted folder, the first (work)Flow will kick off.
An email is sent to the person you have identified as the Reviewer. The Reviewer can open the document from here and then Approve or Reject with comments:
In this example, I’ve approved the document for final Approval, which means Flow will now move it to Reviewed folder.
Once the document is created in the Reviewed Folder, the second Flow will kick off. An email is sent to the final Approver to approve the document:
The document gets approved again and finally ends up in the Approved Folder. The same concept applies when the items are rejected. The documents will be moved to the Rejected Folder:
Keep in mind that you can add more Flows to this process.
For example, once it gets created in the Approved Folder, it then sends an email to the Marketing Department to create and publish the blog.
There’s another template that could work great in this scenario—the Flow does not send mail, instead it notifies the Team Members in the Team Channels.
Using Microsoft Flow to approve and move files is really a lot easier than you think.
Try something simple first, and if it works, add complexity! Always test your Flows each time before you add more actions or conditions. If you don’t and something does not work, you will struggle to find where it failed.
However, when you go to the Run History of your Flow, you can see the success or failure per step.
See example below:
Have fun creating Flows and automating tasks to keep you more efficient and effective in your workplace!
Tracy is a Microsoft MVP and an energetic, hyperactive adrenaline junkie who sees challenges and issues as opportunities and thrives on improving processes, environments and the general quality of life. Her broad knowledge about IT and Business gives her the ability to communicate on both levels and convey meaningful requirements and narrow the (ever present) gap between the two.