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,
Hi @QduBruyn,
the GRAPH request cannot find '(Int) - Group IT Members' group.
Are you sure such group exists?
Hi Expiscornovus,
Here you go:
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:
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.
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.
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)?
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,
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']