Overview
In this blog, we will discuss how we can get the users' information from the specific Security Group in Power Apps.
Use Case
We came across a requirement wherein we need to fetch the information from AD Security Group and need to display it within Power Apps for business logic implementation.
Example
Below is one of the Security Groups created in Microsoft 365.
Here, there are two members added to that Security Group.
In Power Apps, I need information about those two users.
Steps
Step 1
Open your Power Apps Canvas App.
First, we need to add Office 365 Groups Connector. For that,
Go to View Menu, select Data sources.
Search for “Office 365 Groups”. Select the highlighted one. Add that connector in your App.
Once the Connector is added, it will look like this.
Step 2
Open your Power Apps screen and add a button.
Write the following line of code for “OnSelect” event of the button.
- ClearCollect(MembersfromSG,Office365Groups.ListGroupMembers("6aa46539-17ab-494b-b566-4ecbfbd6f45b").value)
Now, here we will store Group member information to the Power Apps collection named – “MembersfromSG”.
The function:
Office365Groups.ListGroupMembers(“Group ID”) returns the information about all the members from that security group.
Now, how can we find that Group ID for the Security Group?
There are two ways to find this.
Find Group ID from Azure Portal
- Open Azure Portal and search for Groups. This will open the following screen.
- Select your security group for more information.
- Copy Object Id. This is your Group ID.
From any SharePoint Groups
- Open any existing SharePoint Group of any test site.
- Add the Security Group as a Member for temporary purposes.
- Click on the name of the Security Group. Copy the Group Id from there.
Use that Group ID in below formula. The formula will look like this.
- ClearCollect(MembersfromSG,Office365Groups.ListGroupMembers("6aa46539-17ab-494b-b566-4ecbfbd6f45b").value)
Now, add a Gallery Control and add Collection as a data source.
This will show the end-user in Gallery.
Step 3
Now, let’s run a solution.
This will show, User’s Display Name and User Principal Name in the Gallery.
Note
The Collection returns so many useful properties. If you wish to check the name of all the returned properties go to View > Collection
This will show a preview of the collection with the schema.
Conclusion
This is how we can get the Members information using Office 365 Groups Connector in Power Apps. I hope this is clear for you now.
Happy Power Apping!!