September 29, 2022

Get Members from the Security Group in Power Apps

We often come across a requirement wherein we need to fetch the information from the Security Group and need to display within Power Apps for Business Logic implementation.

Example:
Below is one of the Security Group created in Microsoft 365. Here, there are two members added to that Security Group.

In Power Apps, we need information about those two users.

Step 1: Open Power Apps Canvas App. First, we need to add Office 365 Groups Connector. For that, 
  1. Go to View Menu, and select Data sources.

  2. Search for “Office 365 Groups”. Select the highlighted one and add a connector to the App.

  3. Once the Connector is added, this will look like this.

Step 2:
  1. Open Power Apps screen and add a button.
  2. Write the following line of code for “On Select” event of the button.
     ClearCollect(MembersfromSG,Office365Groups.ListGroupMembers("GroupID").value)  
  3. Here, MembersfromSG is the Name of the collection. Office365Groups.ListGroupMembers(“Group ID”) returns the information about all the members of that security group.

How can we find that Group ID for the Security Group?
  1. Open Azure Portal and search for Groups. This will open the following screen.
  2. Select your security group for more information.
  3. Copy Object Id. This is the Group ID. We can use this Group ID in the below formula. The formula will look like this.
 ClearCollect(MembersfromSG,Office365Groups.ListGroupMembers("xxxxxxxx-1xxb-4x4b-xxxxxx").value)  

Step 3: Now, add Gallery Control and add Collection as a data source. This will show users in the Gallery.

Step 4: Now, let’s run the solution. This will show, User’s Display Name and User Principal Name.
You can check more properties of members returned by this collection from the executed collection.

Conclusion:
This is how we can get the Member Information using Office 365 Groups Connector in Power Apps.

If you have any questions you can reach out our SharePoint Consulting team here.

No comments:

Post a Comment