Display PowerApp elements based on O365 group membership

My Szenario:

I had to build some app with confidential contents for different user groups.
Some contents may only be visible to a specific group of people.

Solution:

First of all I created two different security groups in O365.
Then I got the groupId through PowerShell (you could also use AzureAD)
Connect-MsolService
Get-MsolGroup | ? displayname -like 
DisplayName”

Use the “OnStart” property of the app to load your group memberships into collections:
ClearCollect(myUsers,Office365Groups.ListGroupMembers(groupId”).value)

Now put the visible property of the element to hide to following:
If(User().Email in myUsers.mail,true,false)

That’s it. It’ll check, if the current logged on user is in the collection of the group members and based on that displays content or not.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...