Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

How to Filter a combobox people picker from a different SharePoint list & populate a text label from selections

Posted on by 51

Hello! 

 

I have 2 Sharepoint Lists for my PowerApp: Projects & Users

Projects has fields ID, Assigned To (mult-select people picker)

Users has fields ID, UserRecord (single-select people picker), Specialty

 

Relevant Powerapps elements:

comboAssignedTo (combobox)

labelSpecialty (label)

 

Outcomes:

  • Filter the Projects.'Assigned To' people picker combobox comboAssignedTo choices to ONLY show people that are in the Users.UserRecord list & save the combobox selections to Projects on form submission
  • Populate labelSpecialty text with the Specialty values from the Users list based on selected items in the combobox comboAssignedTo (concatenated for multiple selections)

 

where I'm at:
I have the comboAssignedTo displaying the records i want with this as the items property:

 

 

With(
 {
 _prefiltered_users: Filter(
 Users, ID > 0
 )
 },
 Sort(
 ForAll(
 Ungroup(
 _prefiltered_users,
 UserRecord 
 ),
 UserRecord
 ),
 DisplayName,
 SortOrder.Ascending
 )
)

 

 

but when I try to save the record, I get a patch error (no details, just "Network error when using Patch function: An error occurred on the server.")

**I've tried refreshing the data connection, same error

 

I've got this for the labelSpecialty label text property so far but it errors out:

 

Concat(comboAssignedTo.SelectedItems, Value & ", ")

 

do I need a 'For All' in here somewhere?

 

Thanks in advance!!

Categories:
  • ImaKickUrAsh Profile Picture
    ImaKickUrAsh 51 on at
    Re: How to Filter a combobox people picker from a different SharePoint list & populate a text label from selections

    this works perfectly! thank you so much for the guidance!

  • Ami K Profile Picture
    Ami K 15,656 on at
    Re: How to Filter a combobox people picker from a different SharePoint list & populate a text label from selections

    @ImaKickUrAsh - my fault I misread your post for item 3. You're correct we can use ForAll here:

     

     

    Concat(
     ForAll(
     comboAssignedTo.SelectedItems As _selections,
     LookUp(
     Users,
     UserRecord.Email = _selections.Email,
     Specialty
     )
     ),
     Value & ";"
    )

     

  • ImaKickUrAsh Profile Picture
    ImaKickUrAsh 51 on at
    Re: How to Filter a combobox people picker from a different SharePoint list & populate a text label from selections

    Thanks for your response & for your awesome blog post that got me most of the way there 🙂

     

    1. got it, thanks - the combobox is displaying the filtered user list now without checking for ID 🙂

    2. apologies for the lack of clarity: I'm not trying to pull the DisplayName from the selected records in the combobox, I'm trying to get the Specialty field value from the Users table for each of the selected combobox items

    example: 

    Users 

    IDUserSpecialty
    1[User Record 1: DisplayName: John]Development
    2[User Record 2: DisplayName: Sarah]Presentations
    3[User Record 3: DisplayName: Sundeep]Documentation

     

    if combobox has John & Sundeep selected, label text should populate "Development; Documentation"

     

    3.1. Yes on EditForm control

    3.2. i republished with the items property update (no other changes to data cards) & it seems to be working now

    3.3. yes multi-select = true

  • Verified answer
    Ami K Profile Picture
    Ami K 15,656 on at
    Re: How to Filter a combobox people picker from a different SharePoint list & populate a text label from selections

    @ImaKickUrAsh - that code looks familiar 😉

     

    1. Assuming your data source is SharePoint, there is no need to use a Filter function to check if a record exists. The reason a Filter was used on my blog was to allow users to optionally Filter the data source first. The below will suffice:

     

     Sort(
     ForAll(
     Ungroup(
     Users,
     UserRecord 
     ),
     UserRecord
     ),
     DisplayName,
     SortOrder.Ascending
     )

     

    2. The Items property of the comboAssignedTo contains a Table of records. If you check my blog again you will see a section where I explain the columns returned in that People data type schema are:

     

    • Claims
    • Department
    • DisplayName
    • Email
    • Job Title
    • Picture

     

    Using "Value" is not going to work here, because that is not a column which exists in that table schema. With this understanding in mind, use:

     

    Concat(comboAssignedTo.SelectedItems,DisplayName & ";")

     

    3. Regarding the error message:

     

    1. Are you using an Edit Form control to save the selected records? (same as my blog?)
    2. Are you certain the "Assigned To" DataCard is the cause for the error? Could you remove all other DataCards and confirm?
    3. Are you certain the "Assigned To" is set to multi-select?

     

    Blog post for reference for anyone else who reads this post:

     

    https://powerusers.microsoft.com/t5/Power-Apps-Community-Blog/Filter-SharePoint-single-or-multi-select-People-Picker-based-on/ba-p/2235959#M1694 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,532

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,050

Leaderboard