Patching a Multi-Select Person Column in SharePoint

Simplify SharePoint user selections using Power Apps’ Patch function. This code snippet enables multi-select choices from a Combo Box, efficiently updating a SharePoint list’s multi-select person column.

Option A – Assign to variable first then use the variable in Patch

//Control Name for Multi Selct

Set(varMultiSelect,
    ForAll(MultiSelectComboBox.SelectedItems As XYZ,
            {'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser", 
                Claims: "i:0#.f|membership|" & XYZ.Mail, 
                Department: XYZ.Department, 
                DisplayName: XYZ.DisplayName, 
                Email: XYZ.Mail, 
                JobTitle: XYZ.JobTitle, 
                Picture: "" 
            } 
    )
);


//PatchCode
Patch(
  ListName,Item,
  {

  SelectedUsers: varMultiSelect
  }
)
;
JavaScript

Option B – Directly do in Patch



//PatchCode
Patch(
  ListName,Item,
{
  SelectedUsers:  ForAll(MultiSelectComboBox.SelectedItems As XYZ,
            {'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser", 
                Claims: "i:0#.f|membership|" & XYZ.Mail, 
                Department: XYZ.Department, 
                DisplayName: XYZ.DisplayName, 
                Email: XYZ.Mail, 
                JobTitle: XYZ.JobTitle, 
                Picture: "" 
            } 
    )

}
)
JavaScript

Leave a Reply

Your email address will not be published. Required fields are marked *