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 a multiselect pe...
Power Apps
Unanswered

Patch a multiselect person column and add current user?

(0) ShareShare
ReportReport
Posted on by 8

I am doing a Powerapp where I am putting registrations for coming guided tours on a factory site.

One function in this is that I have a number of guides that should get a question thru the app, if they are available on a specific tour, or not.

The data is stored in a Sharepoint list, and at the moment the column is a person or group column. It would be good if it could be that, but if the function I want is not possible with a person column, I could change to something else.

My idea is to when the guide clicks a button, a collection is created with the values already in the column named “Kan”, and the current user is added to the collection.

This I have managed to function with the following code in Onselect in the button:

ClearCollect(colKan,

        {

            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",

            Claims: "1:0#.|membership|" & User().Email,

            Department: "",

            DisplayName: User().Email,

            Email: User().Email,

            JobTitle: "",

            Picture: ""

        }

);

ForAll(

    DataCardValue2.SelectedItems,

    Collect(

        colKan,

        {

            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",

            Claims: "1:0#.|membership|" & ThisRecord.Claims,

            Department: "",

            DisplayName: ThisRecord.DisplayName,

            Email: ThisRecord.Email,

            JobTitle: "",

            Picture: ""

        }

    )

)

 

Then I want to patch this collection into the column “Kan” again, so the result would be the values that was there from the beginning with the current user added.

I have tried many different ways, but non is working.
At the moment I tried with the following code added after the code above:

Patch(Table(ForAll(colKan), DataCardValue2.Selected))

But in this case I get an error message “Invalid number of arguments: received 1, expected 2” regarding the Table function.

Is there a way around this or need I change my idea to use a person column?

The complete code under Onselect is at the moment:

ClearCollect(colKan,

        {

            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",

            Claims: "1:0#.|membership|" & User().Email,

            Department: "",

            DisplayName: User().Email,

            Email: User().Email,

            JobTitle: "",

            Picture: ""

        }

);

ForAll(

    DataCardValue2.SelectedItems,

    Collect(

        colKan,

        {

            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",

            Claims: "1:0#.|membership|" & ThisRecord.Claims,

            Department: "",

            DisplayName: ThisRecord.DisplayName,

            Email: ThisRecord.Email,

            JobTitle: "",

            Picture: ""

        }

    )

);

Patch(Table(ForAll(colKan), DataCardValue2.Selected))

Categories:
  • v-yujincui-msft Profile Picture
    Microsoft Employee on at

    Hi @KriLarLys ,

     

    Based on the formula you provided, I found two points that might be worth paying attention to.

    1.  It seems that this place should use Email.

    vyujincuimsft_0-1649405915226.png

    2. The syntax of the Patch() formula seems to be wrong.

    vyujincuimsft_1-1649406215010.png

        Here is link that for your reference.

    https://docs.microsoft.com/en-us/power-apps/maker/canvas-apps/functions/function-patch#modify-or-create-a-set-of-records-in-a-data-source-1

     

    3. Maybe you could try the following formula:

    ClearCollect(
     colKan,
     {
     '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
     Department: "",
     Claims: "i:0#.f|membership|" & User().Email,
     DisplayName: User().FullName,
     Email: User().Email,
     JobTitle: "",
     Picture: ""
     }
    );
    ForAll(
     DataCardValue2.SelectedItems,
     Collect(
     colKan,
     {
     '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
     Department: "",
     Claims: "i:0#.f|membership|" & ThisRecord.Mail,
     DisplayName: ThisRecord.DisplayName,
     Email: ThisRecord.Mail,
     JobTitle: "",
     Picture: ""
     }
     )
    );
    Patch(datasource,BaseRecord,{columnname: colKan})

     

    Best Regards,

    Charlie Choi

  • KriLarLys Profile Picture
    8 on at

    When I try that code I get the following error message:

    KriLarLys_0-1649845368027.png

     

  • KriLarLys Profile Picture
    8 on at

    Actually, the collect part seems to work with my code, but it's the patch part that do not work...

  • v-yujincui-msft Profile Picture
    Microsoft Employee on at

    Hi @KriLarLys ,

     

    I have made a test on my side but it seems that worked fine on my side.

    vyujincuimsft_0-1649892987586.png

    vyujincuimsft_1-1649893166081.png

     

    Here is my formulas:

    ClearCollect( 
     colKan,
     {
     '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
     Department: "",
     Claims: "i:0#.f|membership|" & User().Email,
     DisplayName: User().FullName,
     Email: User().Email,
     JobTitle: "",
     Picture: ""
     }
    );
    ForAll(
     ComboBox1.SelectedItems,
     Collect(
     colKan,
     {
     '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
     Department: "",
     Claims: "i:0#.f|membership|" & ThisRecord.Mail,
     DisplayName: ThisRecord.DisplayName,
     Email: ThisRecord.Mail,
     JobTitle: "",
     Picture: ""
     }
     )
    );
    Patch(BasicInfo,Gallery2.Selected,{principal: colKan})

     Result Screenshot:

    vyujincuimsft_2-1649893251776.png

     

     

    Best Regards,

    Charlie Choi

  • KriLarLys Profile Picture
    8 on at

    Now I got it to function with the code you gave me and after I adjusted it for my list, at least almost. 

    But I still get an error message that I don't know why I get...

    It looks like this:

    KriLarLys_0-1649922823046.png

    Any idea of what that can be?

  • KriLarLys Profile Picture
    8 on at

    I get that error if there are some people in the column already, if it's empty the current user is added perfectly...

  • NicolleAbrahams Profile Picture
    75 on at

    I get the following error when using the same formula any ideas?

    NicolleAbrahams_0-1669644965953.png

     

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 381 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 340

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard