Skip to main content

Integration & IT Modernization

Send a Flow Approval to a SharePoint Group’s Members

Out of the box Microsoft Flow does not currently support getting the members of a SharePoint group. This makes it difficult to utilize existing groups that outdated SharePoint Designer Workflows would use. This leaves two options for a flow creator, A) create a custom list to track approvers, or B) set static emails in the approval Flow itself. By using SharePoint groups instead, we can allow an end user to update this in the future, without having to touch the Flow.

Thankfully with the SharePoint API action available in Flow, we now have the ability to query SharePoint groups. This will return an array of objects containing the users information including the email.

Initial Flow Configuration

To properly configure the approval action we need to first initialize a string variable.

With the variable initialized, we can now call the HTTP Request action to pull the groups members.

Once you select the site, you can configure the Uri to call the group rest API (See Microsoft documentation for more details). If the name of the group can potentially change, you can also use the ID of the group instead by using the syntax: http://<site url>/_api/web/sitegroups(<group id>)/users

After the URI it is also important (and required) that you set the accept and content-type header properties to “application/json;odata=verbose”.

Iterate over the Response

The next step will be to now iterate over the results of this call. The response object that is returned will be in the following format:

{"d":{
"results":[{
"__metadata":{
"id":"http:///_api/Web/GetUserById(16)",
"uri":"http:///_api/Web/GetUserById(16)",
"type":"SP.User"
},
"Groups":{"__deferred":{"uri":"http:///_api/Web/GetUserById(16)/Groups"}},
"Id":16,
"IsHiddenInUI":false,
"LoginName":"i:0#.w|domain\\user1",
"Title":" User1 Display Name ",
"PrincipalType":1,
"Email":"user1@company.com",
"IsSiteAdmin":false,{
"__metadata":{
"type":"SP.UserIdInfo"},
"NameId":"s-0-0-00-000000-0000000000-0000000000-000000",
"NameIdIssuer":"issuer id"
}}, ...]
}}

Flow cannot auto detect the properties returned so we will need to manually enter the values using Workflow Expressions (see workflow definition documentation). In order to iterate over the results, create a for each loop and pass in the value body(‘name of HTTP Action in Flow‘)[‘d’][‘results’].

This will get us into the results array and allow us to reference the different properties (i.e. Email) of each member. Within the For Each loop, we will then create an Append to String Variable” Action.

Again since we do not have the properties auto populated, we will need to use workflow expressions. The value here follows the format items(name of For Each Loop’)[‘Email’].

NOTE: make sure to add a semi-colon after the email. This can either be done with expressions (using the concat function) or can simply just be added after the value (see screenshot above).

Once we are done iterating through the list, we can now configure the Approval action. This can be configured as needed, just make sure to set the Assigned to field to the emailList variable.

Once the approval is configured, you will just need to configure how to handle the approval response with a condition. Feel free to reach out (or leave a comment) if you have any questions.

Thoughts on “Send a Flow Approval to a SharePoint Group’s Members”

  1. Michael Giesbrecht

    thanks for the really great tutorial. is it possible to wrap this process in the request/return function in flow in order to make it into a subroutine that can be called? How can I do that?

  2. Mark Rainbird

    Great article which works really well and has solved a big headache for me – thanks so much.

  3. This looks like a really good article but I’m having problems getting the Flow to work. I think part of the problem is that, in your pictures, you changed the names of the actions. I know this is good practice, but for “how to” purpose such as this, it makes it difficult to understand which action is being used.

    Case in point is your ForEachApprover loop. What action are you using for that? I can’t find a “for each” action. The closest I could fine is “Apply to Each.” Is that the correct one to use? If not, what action is?

    Also, the expression you use in ForEachApprover (body(‘GetApproversGroup’)[‘d’][‘results’] is not explained. I’m guessing “GetApproversGroup” is the name of the group you are getting the members of? What is ‘d’ and ‘results’ for? I don’t know if it is because this article is a year old, but my icon doesn’t look the same for this either. You show a blue icon labeled ‘d.results’ but mine shows a violet icon with ‘fx body(…)’ icon. Am I doing something wrong or did Microsoft change this since your article was written?

    I’m also confused with the “Append to String Variable” explanation. Is that a new action? Or is it supposed to be another step inside ‘ForEachApprover?’ I’ve assumed it is another step within ‘ForEachApprover.’

    Finally, I’m stuck on what value to enter for “Append to String Variable” step. You state that the format is “items(‘name of For Each Loop’)[‘Email’]”. That’s great but how do you find the name of the For Each Loop? Is that “ForEachApprover?” I tried that name in my Flow but it will not accept it. So, I’m stuck.

    Any help you can give for this would be appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Storm Anderson

More from this Author

Follow Us
TwitterLinkedinFacebookYoutubeInstagram