cancel
Showing results for 
Search instead for 
Did you mean: 

"Get Manager" For SharePoint Document Library Approvals

Hey Everyone,

Recently people have been coming to me with a common issue. They're stoked that SharePoint Document libraries are now supported in approvals, but they notice that when triggering off "when a file is created" that you arent able to expose the "get manager" action  in O365 to be able to send approval to the document creators manager dynamically.

 

I went to the team with this dilemma and thanks to @merwan - he showed me this wonderful little workaround that i now want to share with you.

First, lets set up a couple of things ahead of time.

 

This tutorial assumes you have a SharePoint Document library, and for ease of use, its named "Documents"

Next, it also assumes you use O365 in your environment. If you dont have O365, this tutorial wont be as relevant for you.

Ok so first things first, 

 

1. Head to https://flow.microsoft.com and login

2. Click on My Flows

3. Click on "+ Create from blank"

4. Add an action -> Select SharePoint -> "When an existing item is modified" -> enter your SharePoint url and then where it asks you to choose your list.. Manually type "Documents" (or whatever your Document library is named"

blog1.PNG

5. Add an action -> O365 -> Get Manager -> Open the dynamic content picker and use the SharePoint content piece "CreatedBy Email" this tells the O365 service to look up the manager of the person who created the document in the library. We will use this for the approval in a moment.

blog2.PNG

6. Next, Add a condition. (This is where the hackyness of this tutorial comes in. We are going to trick Flow into allowing us to see newly created items, and also acquire the manager of the creator, a function we couldnt achieve logically with the actions and triggers we were provided) and Make the condition read "Modfied" is equal to "Created"

blog3.PNG

7. In the IF YES column, add the "Approvals" Service and choose -> Start an approval.

8. Set all of your fields as desired in the approval email, the one important field being where it says "Assigned to" make sure andpass the "Email" dynamic content piece from O365 which represents the creators manager.

blog4.PNG

9. And voila! Thats all there is to it. 

 

Now obviously, this flow isnt finished. It needs some additional actions under the approval as far as sending email to notify the user of approval or rejection, or maybe a push notification or maybe the Flow copies the file once approved to a seperate location.

 

How would you finish this flow? What steps should i add next?

 

Let me know if you guys have any questions!

 

- Jon L

Senior PM- Flow Team

@PNWAdventureGuy

 

Comments

I'm not sure I understand. When I create a flow with the "when a new item is created" trigger, I am able to add a "get manager" action. What am I not understanding about about the item created vs modified triggers that would impact the use of the get manager action?

Jon, We are in a situation were we do not use the same Email as UPN. I find the Approval flow cannot locate the users manager when email does not match UPN. I have raised issue on the forums but got no good response. Any way to surface UPN instead of email in the dynamic created by content?

@Mike2500 Thats correct - "Create item" refers to creating a list item - The purpose of this blog is a workaround for this same "Get Manager" action, which isnt exposed by default when tryign to use "When a new file is created" for Flowing certain actions off of Document Libraries

@JonL-MSFT, understood, but in step 4, instead of using "When an existing item is modified", you could have just used  "When an item is created", which means you could have avoided the "hacky" step 6. Either trigger is based on the list item, and should have access to the metadata fields that the file triggers lack.

 

@Mike2500 - Ahhhh got it. At the time of writing this, that fix hadnt been deployed yet. Glad to see it rolling out now. Ill erase this post in a few weeks when the rollout is complete.

@JonL-MSFT, could you clarify which fix is rolling out? Is what you're talking about perhaps related to this question I posted earlier today?

 

 

@MikeE the new SharePoint connector rolled out a week ago

 

We now return the

  • URL to the item
  • Name (file name for document libraries, item title for lists)
  • Folder path
  • File identifier

@JonL-MSFT Any help with the issue I posted above Jon? Really I just want to make sure you guys realize/acknowledge out of the box approval flows fail for users that do not have the same UPN as Email address.

So, this missing functionality was entered as a User Voice item in June 2016. The SharePoint list item data for a document is fundamental to any user with SharePoint background. The fact that it is missing is unfathomable to them. Twice now I have seen Flow discarded because the connector does not offer this functionality without this work-around.

The User Voice item is here: https://powerusers.microsoft.com/t5/Flow-Ideas/SharePoint-Files-all-fields-not-just-a-few/idi-p/2882

Meet Our Blog Authors
  • Working daily with Microsoft Cloud to deliver the needs of my company, my customers and various Microsoft communities and forums. | Office 365 | Flow | PowerShell | PowerApps | SharePoint |
  • Co-founder of https://plumsail.com, Office 365 and SharePoint expert. Passionate about design and development of easy to use, convenient and flexible products.
  • Microsoft Business Apps MVP. Owner of ThriveFast, an Office 365 consulting company.
  • 7x Microsoft Business Solutions MVP (CRM)
  • I'm keen in MS technologies, SharePoint, Office 365 and development for them
  • Daniel is a Business Productivity Consultant & Microsoft Business Solutions MVP who is very enthusiastic about all things Office 365, Microsoft Flow, PowerApps, Azure & SharePoint (Online). Since the preview, Daniel has been working with Microsoft Flow and later on with Microsoft PowerApps. That led to him being awarded an MVP Award for Business Solutions. He loves to blog, present and evangelize about improving productivity in the modern workspace with these amazing tools!
  • Michelle is an Office 365 solution architect in Twin Cities, MN. She has been delivering business collaboration solutions for years with her focus on SharePoint and Office 365. Michelle is a recent board member of the Minnesota Office 365 User Group and has been a member of the SharePoint community since 2009. She is a frequent speaker at MNSPUG and SharePoint Saturday and co-chaired the Legal SharePoint User Group for 4 years. Her most frequent projects have involved rolling out a large deployment of Office 365, SharePoint Online intranet, build of a "CHAMPS" Office 365 user adoption program and most recently, SharePoint On-Premise to Online Migration. Michelle is very excited about cloud technology as it is shifting her IT Pro focus to collaboration strategy and technical adoption.
  • I'm a Microsoft Office Servers and Services MVP with a special interest in SharePoint, Office 365, Microsoft Flow, Microsoft Teams and PowerApps. I work at Triad Group Plc ( https://triad.co.uk)
  • Passionate #Programmer #SharePoint #SPFx #Office365 #MSFlow | C-sharpCorner MVP | SharePoint StackOverflow, Github, PnP contributor