Showing results for 
Search instead for 
Did you mean: 
Helper I
Helper I

Exclude Supervisor and Direct Reports from People Picker

I have been asked to build an app that can only be used by 'peers'. Basically, when selecting a recipient, the choices cannot include myself, my supervisor, nor my direct reports (if I have any). I would like this to be a search box with filtered gallery (forgive me if my terms are not correct!) Basically when user starts typing either a name or email address, the gallery displays people that I can select that match the search.

Any help or links to solutions is appreciated! I've read bits and pieces but I don't understand how to put them together yet. Thanks.

Super User
Super User

Hopefully this can get you started:

Office365Users.DirectReportsV2( Office365Users.ManagerV2(  Office365Users.MyProfileV2().userPrincipalName).userPrincipalName).value.displayName

 You can put this into the Items property of a drop-down.

It gets your UPN (user principle name), uses that to look up your manager's UPN and then gets all the direct reports for that UPN (your peers).

Note that Power Apps will throw error messages if the user does not have a manager defined. The only way around that I know is to turn on the experimental setting for 'Formula Level Error Management' but if you do so, thoroughly test the rest of your App as this can change the outcome of existing formulas in your App.

Helper I
Helper I

Thank you. How do I use that as a filter to exclude those names from the choices that appear in the gallery as user types in search box? (I have the search/gallery working just need to exclude ineligible choices.)

Helper I
Helper I

When I tried the code on the gallery, it returns my name and my teammates (same supervisor).
I need to exclude my supervisor and any direct reports (if I have any)

Helpful resources

Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,524)