Microsoft 365 Group membership approval

This is a write-up of something I demonstrated earlier today. In this article I will share how you can use Power Automate to create a membership approval process for Microsoft 365 Groups owners.

Inspiration

This question from QduBruyn:

I’d like to see if I can use Power Automate to automate the process of adding a user to a group after the group owner approves it.

Power Users Community thread: Automate M365 group membership.

Microsoft Forms

Like suggested in the thread we want to start this process with a registration form. In this example I used Microsoft Forms. A user has to be logged on and can submit a request to join a Microsoft 365 Group.

powerusers_microsoftforms

Approval Centre

After submitting a response the flow will try and retrieve the correct group and send an approval to the owner. This owner could approve (or reject) this request via the Approval Centre.

approval_membership

Flow setup

powerusers_membership_approval

1. Add a When a new response is submitted trigger action. Select your Form.

askapproval

2. Add a Get response details action. Select your Form. Make sure you also select the Response Id dynamic content field.

askapproval02

3. Add Get user profile (V2) action. Use the Responders’ Email in the User field.
This action will retrieve the details of the user who submitted the form.

getuserprofile_respondersmail

4. Add a Send an HTTP request (Office 365 Group connector) action. Make sure you use the GET method and the URI from the code snippet below. Also make sure you replace the question by the question from your Form.
This action is to retrieve the specific Microsoft 365 Group.

sendanhttprequest_groupsfilter

5. Add a Condition action. Check if the length of the value property is not equal to zero. If that is the case your HTTP request has found a matching Group. Use the expression below for that length check.
This action is to check if the Microsoft 365 Group exists.

lengthvalue_notequaltozero

6. Add a Start and wait for an approval action within the Condition – If yes section. Select an Approval type, in this example First to respond. Set a Title, I reused the Display Name and the Group Name. Use the expression below in the Assigned To field.

startandwaitforapproval02

7. Add a second Condition action within the Condition – If yes section. Use the Outcome field and check if it is equal to Approve.
This action is to check if the owner approved the request.

outcome_approve

8. Add a Add member to group action within the second Condition – If yes section. Use the Reponders’ Email for the User Principal Name. Use the expression below for the Group Id.

outcome_approved_addmember

That should be it for the setup.

When you test it you should see the new member be listed in the Group (after approval) like below.

add_membership

Happy testing!

You may also like...

2 Responses

  1. Carl says:

    Thank you for taking the time to blog about this. We have this exact requiremnt so this post has been very helpful.

    I have it working as you listed it however I want to send the approval email to all the group owners and let any of them response rather than just the first one.

    From following your code it seems you select only the first owner to send to.

    I have tried getting the list of owners then using this as an input into a “Apply to each” control however as soon as I do this the actions in the loop never run.

    Would you be able to show how to achieve the ability for any group owner to approve the request?

  2. Dennis says:

    Hi Carl,

    In my setup I was using a First to respond approval type. That’s why only one owner was needed. You could use a Select action after step 4 to only retrieve the email addresses of all owners.

    body('Send_an_HTTP_request')['value'] in the From field

    item()['mail'] in the Map field (switch to text mode with the icon on the right side)

    After that you can join them together with an semi colon character so you can use it in the Assigned To field of the Start and wait for an approval action.
    join(body('Select'), ';')

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.