Power Apps Patch method for Multiselect people picker field

I have text box field in power app canvas app where I would like to populate office 365 users in search.

We have enabled multiple users selection.

Connect office 365 users in datasources

items: Office365Users.SearchUser({searchTerm:cbusername.SearchText,top:10})

Here, cbusername is the text box field name

while doing patch, we want to save it in SP List.

Refer this video: https://www.youtube.com/watch?v=bmft4JFWJiY

In the below example, I am using Office 365 users in textbox named "cbusername" and "cbapproversnames".

First using ForAll loop for office 365 users connected text box, Inside creating a collection and assigning ThisRecord.Mail ... values to the collection.


ForAll(

            cbusername.SelectedItems,

            Collect(

                ColPeopleToPatch,

                {

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

                    Claims: "i:0#.f|membership|"&ThisRecord.Mail,

                    Department:"",

                    DisplayName:ThisRecord.DisplayName,

                    Email:ThisRecord.Mail,

                    JobTitle:"",

                    Picture:""

                }

            )

        );

        ForAll(

            cbapproversnames.SelectedItems,

            Collect(

                ColApproversPersonsToPatch,

                {

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

                    Claims: "i:0#.f|membership|"&ThisRecord.Mail,

                    Department:"",

                    DisplayName:ThisRecord.DisplayName,

                    Email:ThisRecord.Mail,

                    JobTitle:"",

                    Picture:""

                }

            )

        );

        Patch(

            'Requests for Access',

            Defaults('Requests for Access'),

            {

                Title: "",

                Requester: ColPeopleToPatch,

                Approvers: ColApproversPersonsToPatch,

                'Permission Level': ListBoxPermissionLevel.Selected.PermissionLevelName,

                PermissionLevelID: ListBoxPermissionLevel.Selected.PermissionLevelID,

                Status: "Pending",

                Comments:txt_Comments.Text,

                SiteURL:txt_SiteURL.Text

            }

        );


Comments

Popular posts from this blog

Powerapps overcome 2000 item limit from any datasource

PowerApps multiselect cascading dropdown and save an item to SharePoint List

Multi select cascading dropdown in Power Apps