in Flow

How to send approval requests to groups in Microsoft Flow

Context

The Microsoft Flow Approvals connector does not support sending approval requests to groups today.

If you want to send an approval request to an email address belonging to a group, as illustrated in the screenshot below:

The following issue may occur:

BadRequest. The request failed. Error code: 'InvalidApprovalCreateRequestAssignedToNoValidUsers'. Error Message: 'Required field 'assignedTo' contained no valid users in the organization'.

This error is expected because the email address used in the Assigned to field is not matching any valid user.

Workaround

The workaround is to first get the members from the group, and append their email addresses to a string variable, and then use the variable in the recipient field on the Approvals action.

This workaround will send the approval request to the mailbox of each group member. It will not send the approval request to the group mailbox.

To test this workaround, create a flow that starts When an item is created in a SharePoint list.

Then continue with a Initialize variable action and initialize a string variable varEmails

Search for the Office 365 Groups connector and add the List group members action.

Pick the group from the Group Id drop-down or, if you can't find it in the list, enter the group GUID in the field.

This action works with Office 365 Groups, Security Groups, and Distribution Lists.

To get the group GUID, either use PowerShell:

get-azureadgroup -SearchString "somedistributionlist" | select-object objectid

ObjectId
——–
acb1e500-be76-4506-a816-442ccc917f14

Or go to Azure AD groups and search for the group and get the GUID that way:

Don't forget to change the pagination settings of the List group members action if you have more than 999 members in your group.

Turning on pagination will ensure that all members will be pulled by the action.

Next add an Apply to each control and point it to members array coming from List group members action output.

Inside the Apply to each control add an Append to string variable action and append the Mail item to the varEmails variable

Don't forget to add the semicolon ; after the Mail item to make sure the email addresses are correctly separated in the string enumeration.

Lastly, add the Start and wait for an approval action and put the varEmails variable in the the Assigned to field.

The flow run should look like this:

The entire flow should look like this:

You can download this flow from here.

Write a Comment

Comment