web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Automate M365 group me...
Power Automate
Unanswered

Automate M365 group membership

(0) ShareShare
ReportReport
Posted on by 5

Hi There,

 

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.

 

This refers to M365 groups, Teams and distribution lists.

 

So a user would, say, complete a form to become a member of an existing M365 group, team or distribution list, the automation then checks that group and send an approval to it's owners to approve. Once approves, it adds the member to group/team/dl.

 

Is this possible?

 

Thanks,

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @QduBruyn,

     

    Yes, I think this would be possible. You could use the Graph API to filter for the correct group and retrieve the owners. After that you could start and approval and wait for the outcome. If that equals approve you could add the member.

     

    Below is an example of that approach.

    This is a basic setup. You might want to check if the Send an HTTP request results are not empty for example. Additionally this current example only uses the first owner listed, you might want to change that as well.

     

    Uri for the Send an HTTP request action:

    https://graph.microsoft.com/v1.0/groups/?$filter=displayName eq '@{outputs('Get_response_details')?['body/r15d7725d8635470fbafe790d5a824af5']}'&$expand=owners($select=mail)

     

    Expression used in the Assigned To field of the Start and wait for approval action:

    body('Send_an_HTTP_request')['value'][0]['owners'][0]['mail']

     

    Expression used in the Group Id field of the Add member to Group action:

    body('Send_an_HTTP_request')['value'][0]['id']

     

    approvalformembershipgroup.png

  • QduBruyn Profile Picture
    5 on at

    Hi There,

     

    Thanks for your reply, I tried it.

     

    First the Send an Http request didn't work, but tried again then that part worked.

     

    Then on the Start and wait for approval, with your string, I keep getting the following:

     

    InvalidTemplate. Unable to process template language expressions in action 'Start_and_wait_for_an_approval' inputs at line '0' and column '0': 'The template language expression 'body('Send_an_HTTP_request')['value'][0]['owners'][0]['mail']' cannot be evaluated because array index '0' cannot be selected from empty array. Please see https://aka.ms/logicexpressions for usage details.'.

     

    Any idea why that may be? I copied it excatly as you said and the previous step was successful?

     

    Thanks,

  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at

    Hi @QduBruyn,

     

    The error suggests it cannot find the mail value because it did not find any group. Can you share a screenshot of your failed flow run and specifically the Send an HTTP request action (expanded to show the input/output sections)?

  • stayinginsync Profile Picture
    139 on at

    @QduBruyn 

     

    UPDATE - IGNORE THIS.  It works now.

     

    I took a different approach, but this is specifically for when a new Team is created and curious as to your thoughts.

     

    First, if I manually run this Flow, without any additional work, it works just fine.  It will add all the Owners from an existing group as an Owners of a newly created Team:

     

    Screen Shot 2022-03-27 at 2.17.45 PM.png

    stayinginsync_0-1648483934645.png

     

    BUT, if I make 2 small changes, it no longer works.  First, instead of having a manual trigger, it is triggered by a new item being added to SharePoint, and the other is the approval.  Note, the "Get HTTP Request & Parse JSON are the same actions in both flows.

     

    stayinginsync_1-1648484196464.png

     

    stayinginsync_2-1648484271585.png

     

    Except now I'm getting - Action 'Send_an_HTTP_request' failed

     

     

     

    Resource 'GroupID' does not exist or one of its queried reference-property objects are not present.

     

     

     

  • QduBruyn Profile Picture
    5 on at

    Hi Expiscornovus,

     

    Here you go:

    QduBruyn_2-1648556301675.png

    {
        "host": {
            "connectionReferenceName""shared_office365groups",
            "operationId""HttpRequest"
        },
        "parameters": {
            "Uri""https://graph.microsoft.com/v1.0/groups/?$filter=displayName eq '(Int) - Group IT Members'&$expand=owners($select=mail)",
            "Method""GET",
            "ContentType""application/json"
        }
    {
        "statusCode"200,
        "headers": {
            "Transfer-Encoding""chunked",
            "Vary""Accept-Encoding",
            "Strict-Transport-Security""max-age=31536000",
            "request-id""55f193f8-92da-4746-b194-21dd1a91914c",
            "client-request-id""55f193f8-92da-4746-b194-21dd1a91914c",
            "x-ms-ags-diagnostic""{\"ServerInfo\":{\"DataCenter\":\"France Central\",\"Slice\":\"E\",\"Ring\":\"5\",\"ScaleUnit\":\"000\",\"RoleInstance\":\"PA1PEPF0004F032\"}}",
            "x-ms-resource-unit""2",
            "OData-Version""4.0",
            "Timing-Allow-Origin""*",
            "x-ms-apihub-cached-response""false",
            "x-ms-apihub-obo""true",
            "Cache-Control""no-cache",
            "Date""Mon, 28 Mar 2022 13:44:20 GMT",
            "Content-Type""application/json",
            "Content-Length""95"
        },
        "body": {
            "value": []
        }
     
     

     

     

  • VictorIvanidze Profile Picture
    13,073 on at

    Hi @QduBruyn,

    the GRAPH request cannot find '(Int) - Group IT Members' group.

    Are you sure such group exists? 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard