kmax01
kmax01

Reputation: 69

Filter PowerApp Gallery if a user exists in Azure AD Group

Is it possible to filter a gallery in Power App based on the Azure AD security goup? I am currently using email addresses stored in sharepoint list column to filter the gallery. Now, I want to filter the gallery based on Ad group. How should it work? Sharepoint list name is Orders. List column that stores email addresses is called Approvers. I can store the group names or group IDs in the approvers column. If the current user exists in AD Group A, it should filter the orders where AD group A is stored for orders. If the current user exists in AD Group B, it should filter the data where AD group B is stored for orders.

I have already assigend different screens based on the groups but unable to get the idea how the gallery should be filtered based on the groups.

Thanks in advance

This checks if the user exists in a specific group and return true or false. If true it takes the user to specific view otherwise the standard view.

Set(varGlobalUser,AzureAD.GetUser(User().Email).userPrincipalName); Set(varMemberAzureADGroup,!IsEmpty(AzureAD.CheckMemberGroupsV2(varGlobalUser,["AD group ID"]).value));

But couldn't build logic to apply on power app gallery.

Upvotes: 0

Views: 947

Answers (1)

Ganesh Sanap - MVP
Ganesh Sanap - MVP

Reputation: 2228

If you are getting correct boolean value in varMemberAzureADGroup variable based on current user groups then you can use formula like below in items property of gallery control:

If(
    varMemberAzureADGroup,
    //Filter based on common column and user memebership
    Filter(ListDataSourceName, GroupIDColumn = varGroupID),
    //Show All items in data source
    ListDataSourceName
)

Where, GroupIDColumn is the name of your column in SharePoint.

Upvotes: 0

Related Questions