cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PeterDonohue
Level: Powered On

Filter Gallery By Current User - People Picker SP List

Hey good people, another head scratcher that seems to end in the response "Don't Use People Picker type in Sharepoint if you want to use PowerApps".

 

I have a SP list with a column Dispatch - This is a people picker type

I have a gallery that I would like to Filter so it only displays items in the dispatch column that = Current User

 

I just constantly get a delegation warning and no results.

 

I have tried the User() function but this doesn't seem any better

I have tried setting the variable OnVisible but this doesn't work 

 

It seems every time the People Picker is used with a filter it results in failure Smiley Sad 

8 REPLIES 8
Dawidvh
Level 10

Re: Filter Gallery By Current User - People Picker SP List

Hi @PeterDonohue

 

I love Person\Group columns when working in a SharePoint list only, but am sad to say that when you start consuming that list in PowerApps, it does complicate matters. Do users interact with the SharePoint list directly as well, or only through PowerApps?

 

a) First, we always write the user id into a variable OnStart for the app. If you user user().Email directly in the filter you will have delegation problems regardless of the rest of your formula. Even if you stored the user email address in a simple text field in SharePoint you will still get a delegation warning if you compared it against user().Email at filter time.

Set(varUserId,User().Email)

b) Rember that the Employee\Group column can be seen a record in itself, so you have to specify the property of the column that you want to filter agains. In the below example I am using the Email Address.

Filter(Leave,Employee.Email = varUserId)

This filter works, but you will still face a delegation concern.

 

I am not aware of any way to fix the delegation out of the box. If you have more than 2000 records you can consider is to create another text column in the SharePoint list, and create a Flow to populate the column by extracting the email address from the people column, but this will be interesting and consume a Flow run everytime a record is created. (Unfortunately SharePoint Calculated Columns also can't user the people\group column)

 

Let me know if you don't come right and if you need help to put the flow together.

 

twitter: @dawidvh

youTube: https://www.youtube.com/channel/UCIMe_ErQZP5chbI9UyW0xLw

>>If you found this reply helpful, please mark this as the answer to close the topic and make it easier to find for other people with similar questions.<<

 

 

 

PeterDonohue
Level: Powered On

Re: Filter Gallery By Current User - People Picker SP List

Thanks for the response mate, really appreciate it. I think this might be just one of those really significant failings of the application suite unfortunately. I'll find a work around 

Community Support Team
Community Support Team

Re: Filter Gallery By Current User - People Picker SP List

Hi @PeterDonohue,

 

Do you want to filter the gallery ‘s dispatch column by current user?

I think you should change your formula expression’s “=” to “in”.

If you search multiple names in your one column you use “in’.

 

You can try following workaround.

I test as next:

Data Source:

20190208PeoplePicker(my SP list name)

Dispatch(Person or Group type column)

20190208sp1.png

App Test:

Gallery.Items: Filter('20190208PeoplePicker',User().FullName in Dispatch.DisplayName)

20190208peoplepickerapptest1.jpg

 

Hope this can be helpful.

Best Regards.

Yumia

Dawidvh
Level 10

Re: Filter Gallery By Current User - People Picker SP List

Hi @v-yuxima-msft

 

The in operator is also not delegatable (please ask the guys in your office when it will be Smiley Happy), even if you write the username into a variable as mentioned in my post above which is delegatable, the in operator will break the delegation.

 

twitter: @dawidvh

youTube: https://www.youtube.com/channel/UCIMe_ErQZP5chbI9UyW0xLw

>>If you found this reply helpful, please mark this as the answer to close the topic and make it easier to find for other people with similar questions.<<

PeterDonohue
Level: Powered On

Re: Filter Gallery By Current User - People Picker SP List

After a bunch of digging I figured it out. The delgation warning still persists and I will set up a warning system to negate this but the culprit was the list item set to multiple selections AND the name (presence).

 

I changed it to single selection only

Only Name

Set the variable OnStart (although I may move this to OnVisible)

 

Set(CurrentUser,Office365Users.MyProfile().DisplayName)

Call the variable 

Filter('Media Enquiries',Dispatch.DisplayName = CurrentUser)

All working just with a lovely yellow triangle Smiley Happy

 

Thanks again people Smiley Happy

Yuko_d_Suzuki
Level: Powered On

Re: Filter Gallery By Current User - People Picker SP List

I am facing a similar issue and confirmed it works when I changed User/Group item to single selection. But I need to keep it to multiple selections. Can anybody show a workaround?

PeterDonohue
Level: Powered On

Re: Filter Gallery By Current User - People Picker SP List

I'm just guessing, but I would imagine that this would be a fundamental issue as you are asking for a filter by 1, but giving people the opportunity to select multiple so what happens in the case of multiple people being selected, does it then filter by all selected? Programatically I'd imagine this would cause an issue. 

 

The only way I can think of is to add multile columns for people, or maybe populate a combo box with the selection ande try to filter by the selected values in the combo box?Maybe? Smiley Happy

Yuko_d_Suzuki
Level: Powered On

Re: Filter Gallery By Current User - People Picker SP List

I think I found a workaround. It is a bit complicated though.

I prepared 2 galleries for the same data source. The first one is to show all items of the data source with a text box which shows e-mail addresses of the selected people.

PersonInChargeEmail = Concat(ThisItem.PersonInCharge, Email)

Add another label to show if the current user is included in the selected people.

IsMine = If(User().Email in PersonInChargeEmail.Text,"true")

 In this case, the label "IsMine" shows "true" if the current user is included in the "PersonInCharge" - people picker which allows multiple selections.

Then configured OnVisible as below - collect items with "true" value only.

OnVisible = ClearCollect(MyItems,Filter(Gallery1.AllItems,IsMine.Text="true"))

Finally, show all the items of the "MyItems" collection in the 2nd gallery.

Gallery2.Items = MyItems

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, August 21st at 8am PDT

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

SixthImage

Power Summit Australia 2019

August 20-23rd 2019

Users Online
Currently online: 36 members 4,066 guests
Please welcome our newest community members: