cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
asri_zainal
Helper I
Helper I

SOLVED: Filter gallery to exclude specific user in Office365 Group

Hi,

I'm working on the Leave Request App and have been customizing a lot to it and it currently works as I hope it would be except for 1 thing.

 

The initial template allows requestor to select any users in the organization as a leave approver which is not good.

I have modified this portion of code(GalleryUserSearchResultsApproverPopup in SelectApproverPopup screen) to only allow members of an Office365 group called "Leave Approvers".

 

If(!IsBlank(Trim(TextInputSearchFilter.Text)),Filter(Office365Users.SearchUser({searchTerm:Trim(TextInputSearchFilter.Text), top: 15}),Mail in Office365Groups.ListGroupMembers("ID-HERE").value.mail))

Now this works well, the search results limit to members of this group instead of everyone in the organization.

This got me thinking further on how to improve this by not allowing the requestor to set themselves as leave approver(In case these users are already member of the Leave Approver Group).

 

I have tried various ways by modifying the filter logic however weren't successful hence posting on here hoping someone can point me in the right direction.

 

Goal is to exclude 1 user from the search results = requestor(can use email, display name or whatever information that is linked to the requestor)

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @asri_zainal,

Do you not want the requesters to set themselves as leave approver?

 

I have made a test on my side, please take a try with the following workaround:7.JPG

Set the Items property of the GalleryChangeApprover Gallery within the ChangeApproverScreen to following formula:

If(
!IsBlank(Trim(TextInputSearchUser.Text)),
Filter(
Office365Users.SearchUser({searchTerm:Trim(TextInputSearchUser.Text)}),
Mail in Office365Groups.ListGroupMembers(Dropdown1.Selected.id).value.mail,
Mail<>User().Email /* <-- Add formula here */
)
)

On your side, you should type the following formula:

If(
!IsBlank(Trim(TextInputSearchFilter.Text)),
Filter(
Office365Users.SearchUser({searchTerm:Trim(TextInputSearchFilter.Text), top: 15}),
Mail in Office365Groups.ListGroupMembers("ID-HERE").value.mail,
Mail<>User().Email /* <-- Modify here */
)
)

More details about User function in PowerApps, please check the following article:

User function

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-xida-msft
Community Support
Community Support

Hi @asri_zainal,

Do you not want the requesters to set themselves as leave approver?

 

I have made a test on my side, please take a try with the following workaround:7.JPG

Set the Items property of the GalleryChangeApprover Gallery within the ChangeApproverScreen to following formula:

If(
!IsBlank(Trim(TextInputSearchUser.Text)),
Filter(
Office365Users.SearchUser({searchTerm:Trim(TextInputSearchUser.Text)}),
Mail in Office365Groups.ListGroupMembers(Dropdown1.Selected.id).value.mail,
Mail<>User().Email /* <-- Add formula here */
)
)

On your side, you should type the following formula:

If(
!IsBlank(Trim(TextInputSearchFilter.Text)),
Filter(
Office365Users.SearchUser({searchTerm:Trim(TextInputSearchFilter.Text), top: 15}),
Mail in Office365Groups.ListGroupMembers("ID-HERE").value.mail,
Mail<>User().Email /* <-- Modify here */
)
)

More details about User function in PowerApps, please check the following article:

User function

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post


@v-xida-msft wrote:

Hi @asri_zainal,

Do you not want the requesters to set themselves as leave approver?

 

I have made a test on my side, please take a try with the following workaround:7.JPG

Set the Items property of the GalleryChangeApprover Gallery within the ChangeApproverScreen to following formula:

If(
!IsBlank(Trim(TextInputSearchUser.Text)),
Filter(
Office365Users.SearchUser({searchTerm:Trim(TextInputSearchUser.Text)}),
Mail in Office365Groups.ListGroupMembers(Dropdown1.Selected.id).value.mail,
Mail<>User().Email /* <-- Add formula here */
)
)

On your side, you should type the following formula:

If(
!IsBlank(Trim(TextInputSearchFilter.Text)),
Filter(
Office365Users.SearchUser({searchTerm:Trim(TextInputSearchFilter.Text), top: 15}),
Mail in Office365Groups.ListGroupMembers("ID-HERE").value.mail,
Mail<>User().Email /* <-- Modify here */
)
)

More details about User function in PowerApps, please check the following article:

User function

 

Best regards,

Kris


Perfect! Can't believe it was that simple...

 

Thank you Kris - you're a star!



Hi @asri_zainal,

Have you solved your problem?

 

If you have solved your problem, please click "Accept as Solution" on the reply that contains the solution so that this thread will be marked for other users to easily identify.

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,618)