web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch People field tha...
Power Apps
Answered

Patch People field that allows multiple values

(0) ShareShare
ReportReport
Posted on by 26

I am trying to Patch a SharePoint People field that allows multiple values. I have been able to patch a SharePoint People column as long as it contains one value...but if the People column allows multiple values, my patch statement only gets the first value and does not work properly. I don't want to use a form and would really prefer Patch, but I'm stuck on this. My People values are coming from a combo-box in which the user inputs multiple people...anywhere from 1 to 6 people...so the Patch statement can't be hardcoded and must be able to read the input from the user via the combo box. 

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @bregan507 

    You will need to supply a table of persons to the column during patch.

    Please have a look at this post, it should explain pretty much what you are trying to do.

     

    I hope this is helpful for you.

  • bregan507 Profile Picture
    26 on at

    Thank you...that worked. But I'm having a weird thing happen now...
    If I put in person1, person2 into the combo box and click submit, the patch works now. All is well. When I go back to the same record, and add another name, it updates the record but deletes person1, person2 out of the SharePoint list. In other words, When I go to the record to edit it and input person1, person2 into an empty field and click submit, it works. When I then go back to the same record, and modify that combo box (that already has values) to read: person1, person2, person3 and click submit, it updates the record...but if I go back to that same record now, it shows person3 as the only entry. Any ideas on why that is happening? 

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @bregan507 

    Yes, adding in additional people does not "add" them, it replaces the list.

    If you want to add people, then you would need to supply in your patch, the entire table of people (the existing and the added).

    If you have a hard time working that out, then let me know what the DefaultSelectedItems property of your ComboBox is and I can help work it out with you.

     

     

  • bregan507 Profile Picture
    26 on at

    You're awesome...thank you. I'm new to PowerApps (this is my first app). I've been working in InfoPath for years, and trying to figure out PowerApps...it's different. I very much appreciate you helping me...thank you again. 

    On my cboReviewers (this will write to the Multiple Person field in SharePoint) the DefaultSelectedItems: varRecord.Reviewer (When the user click the record in the gallary on another screen, the OnSelect is: Set(varRecord,ThisItem);Navigate(ScreenEdit,Fade)

  • bregan507 Profile Picture
    26 on at

    My patch statement is something like this: (I can't paste it exactly because I can't login to this forum from my work computer so I'm typing it in manually here)
    Patch(
        cqdata,
        varRecord,
        {
            Reviewer: 
                ForAll(cboReviewer.SelectedItems, 
                {
                    '@odata.type':...
                    Claims: Mail, 
                    Department: "", 
                    Email: Mail, 
                    JobTitle: "", 
                    Picture: "",
                })
         })

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @bregan507 

    No worries.  I know going from InfoPath to PowerApps is like moving from Earth to Mars...eventually you learn to breathe the air 😉

     

    So, the first thing to note about your desired solution is that you will NOT be able to remove people from the Person column in your list as you are only going to be appending to the list each time.

     

    So, here would be where I'd start - take the formula for building the multi-Person column from what was suggested before and then combine with the selected items.  

    Here is how that would look:

    ForAll(
     Filter(Split(Concat(cboReviewers.SelectedItems, Email & ";") & Concat(varRecord.Reviewer, Email & ";"), ";"), !IsBlank(Result)),
     {
     '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
     Claims: Result,
     Department: "",
     DisplayName: Result,
     Email: Result, 
     JobTitle: ".",
     Picture: "."
     }
     )

    This will turn the selected items in the combo and the current record items into a string (with the Concat), then it splits it and uses that in the ForAll (Filtered to remove blanks).  You will have duplicates most likely, but SharePoint will sort that out.

     

    See how that goes for you.

     

  • bregan507 Profile Picture
    26 on at

    Thank you again for trying to help me...this seems like a lot of frustration. This seemed to work then it didn't work - it's weird - I put in the code, and it looks fine. I run it and it doesn't update. I go back to the code and now there are red squiggly lines everywhere and I didn't change the code. Earlier, I used the code and it updated the field but wouldn't update a blank value. It's like the code works sometime, and shows errors other times. I've scraped all my changes and reinput your code now nothing is updating and the red squiggly lines disappear if I add a space somewhere in the code or remove the "requestor" code. My goal is to get this to work like it did in InfoPath...where the user can add 1, multiple or 0 items in the "Reviewer" field.  Thank you again for your time helping me. 

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @bregan507 

    If you are actually trying to submit back an Empty record, you will need to make sure that you have the "Formula level error management" option turned on in your Advanced app settings.  Otherwise it will not work.

    What is your Formula now showing?  What are the red-squiggly lines telling you the error is? (hover over them to get the error)

  • bregan507 Profile Picture
    26 on at

    It's weird...the same code that was giving me red lines just started working. I closed and re-opened the window and that seemed to help. The patch is now working but I need one more thing...If the user wants to remove someone, this is not removing. Thank you. 

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @bregan507 

    You need to always look at the error that you are getting to determine the cause.  If you are trying to write back an invalid value to the datasource, you will see datasource errors in the red-squiggly underlines.  

    But make sure the formula level error management is on!

     

    I did mention in the start of this:

    So, the first thing to note about your desired solution is that you will NOT be able to remove people from the Person column in your list as you are only going to be appending to the list each time.

     

    So....let's revisit that.  You stated this in an earlier post:

    When I go back to the same record, and add another name, it updates the record but deletes person1, person2 out of the SharePoint list

    In re-reading that, I believe that perhaps what you might have been saying is that the original people selected (Person1 and Person2) were NOT showing in the combobox selections and that if you add Person3 in the ComboBox that Person1 and 2 go away and you are left with person3.  This is accurate if Person1 and Person2 are not showing as selected items in the list already.

    So, I believe we might want to focus on that aspect.

    Can you confirm the above?

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 393 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 278 Most Valuable Professional

Last 30 days Overall leaderboard