PowerApps – Remove Person from Multiselect Person Column from SharePoint

Business Requirement

I came to know the business requirement to have a screen to let users click a delete icon for a person’s entry in a gallery, which will then remove that person from the selected list in SharePoint.

Solution

We will be using PowerApps to fulfill this requirement. The screen has Gallery within the gallery to display the users. We call it MainGallery and PersonGallery. The  MainGallery to display the items, and PersonGallery to display the person’s list

Main Gallery

  • Insert the Gallery (Name: MainGallery) and set Items property to

SPListName

Person Gallery(Sub Gallery)

  • Select the main Gallery and insert another gallery (Sub Gallery – Name: PersonGallery)
  • Set the Items property of PersonGallery to (MultiplePeople – ColumnName)

ThisItem.MultiplePeople

  • Insert label and Set Text property to

ThisItem.DisplayName

  • Insert Icon and set an icon to something (X or Trash)

Sample UI

Setup

Action/Steps

Set the OnSelect property of Trash Icon to

We have 4 steps and splitting into multiple for readability

  1. Get the Email for the person to delete

Set(
personToRemove,
ThisItem.Email
);

2. Collect current All persons email id’s

ClearCollect(
colAllPersons,
ForAll(
MainGallery.Selected.MultiplePeople,
{PersonEmailId: Email}
)
);

3. Remove the person from the collection

Remove(
colAllPersons,
Filter(
colAllPersons,
PersonEmailId = personToRemove
)
);

4. Patch the updated list to Sharepoint (IssueTraker – SP List)

Patch(
IssueTracker,
LookUp(
IssueTracker,
ID = MainGallery.Selected.ID
),
{
MultiplePeople: ForAll(
colAllPersons,
{
‘@odata.type’: “#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser”,
Claims: “i:0#.f|membership|” & PersonEmailId,
Department: “”,
DisplayName: “”,
Email: PersonEmailId,
JobTitle: “”,
Picture: “”
}
)
}
)

Remove Person in Action

Leave a Reply

Your email address will not be published.