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

Collect and Patch multiple person column from combobox

I have a gallery with several fields, including one SharePoint multi-person field, which in PowerApps is a ComboBox that looks up the Microsoft users.

 

I cannot get the multi-person field to patch consistently. It was working, then it wasn't, so I changed the code in the Collect to MyComboBox.SelectedItems, as I saw in an article online. That worked, for a while, so I uncommented and deleted my previous code...

 

Now, it MyComboBox.SelectedItems has stopped working. It still writes to my collection fine, but when I go to patch it doesn't save to the SharePoint list, even though there is no error (I have a success/fail message and it says 'success').

 

I cannot work out the right syntax and/or remember my previous code. I know it was something with a ForAll and some variation of:

{
    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
    Claims: "i:0#.f|membership|" & ThisRecord.Mail,
    Department: "",
    DisplayName: ThisRecord.DisplayName,
    Email: ThisRecord.Mail,
    JobTitle: "",
    Picture: ""
}

Nothing I find online seems to be collecting from a ComboBox, but rather manually adding a table with specific people, which is not what I need.

Can someone help me please?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @RABronn ,

 

I assume the Items of the Combo box as follows:

vjefferni_0-1658307870541.png

 

So DefaultSelectedItems of the same Combo box will be:

vjefferni_1-1658307903947.png

Filter(Office365Users.SearchUserV2().value, DisplayName in ThisItem.Assigned.DisplayName)

 

Best regards,

Community Support Team _ Jeffer Ni

If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

5 REPLIES 5
RandyHayes
Super User
Super User

@RABronn 

What is your entire formula?  Your formula shows "ThisRecord" in it.  That indicates that you are either in a Form with this formula or that you have additional formula surrounding this chunk of it.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

That was just an example, but I've just worked out what I had before (finally), and updated my formula to that, which is working (formula below).

I've also worked out why it wasn't working... it's because the DefaultSelectedItems isn't working correctly (it puts the DisplayName in but isn't selecting the person. I just have it as ThisItem.Assigned currently, which obviously isn't correct. I guess I need to do a ForAll and LookUp for each person that is selected in the SharePoint list? How do I do that?

Currently it works for ComboBoxes that didn't have anything in previously, but not if I am adding items when something is already there (because my collection is pulling incomplete data for the existing people).

If(
    ThisItem.ID in colProjectListStatusView.ID,
    Update(
        colProjectListStatusView,
        LookUp(
            colProjectListStatusView,
            ID = ThisItem.ID
        ),
        {
            ID: ThisItem.ID,
            Title: txtProject.Text,
            StatusMain: cbStatusMain_1.Selected.Status,
            StatusDetail: cbStatusDetail_1.Selected.ShortenedActiveList,
            Assigned: ForAll(
                valAssigned_1.SelectedItems,
                {
                    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                    Claims: "i:0#.f|membership|" & Lower(Mail),
                    Department: "",
                    DisplayName: DisplayName,
                    Email: Mail,
                    JobTitle: "",
                    Picture: ""
                }
            ),
            AssignedInitials: lblAssigned1.Text,
            Priority2: cbPriority_1.Selected.Value
        }
    ),
    Collect(
        colProjectListStatusView,
        {
            ID: ThisItem.ID,
            Title: txtProject.Text,
            StatusMain: cbStatusMain_1.Selected.Status,
            StatusDetail: cbStatusDetail_1.Selected.ShortenedActiveList,
            Assigned: ForAll(
                valAssigned_1.SelectedItems,
                {
                    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
                    Claims: "i:0#.f|membership|" & Lower(Mail),
                    Department: "",
                    DisplayName: DisplayName,
                    Email: Mail,
                    JobTitle: "",
                    Picture: ""
                }
            ),
            AssignedInitials: lblAssigned1.Text,
            Priority2: cbPriority_1.Selected.Value
        }
    )
)

I managed to get the DefaultSelectedItems to work off a label that Concats the values from the Multi-Person column for now. It isn't the most elegant solution though, so if there is a better way, please let me know.

Hi @RABronn ,

 

I assume the Items of the Combo box as follows:

vjefferni_0-1658307870541.png

 

So DefaultSelectedItems of the same Combo box will be:

vjefferni_1-1658307903947.png

Filter(Office365Users.SearchUserV2().value, DisplayName in ThisItem.Assigned.DisplayName)

 

Best regards,

Community Support Team _ Jeffer Ni

If this post helps, then please consider Accept it as the solution to help the other members find it.

Hi @v-jefferni 
That works, thank you. I tried various iterations, but forgot the simple solution! (I still get confused with the various ways of dealing with different PowerApps inputs and SharePoint columns.)

Helpful resources

Announcements
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 (6,769)