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 main gallery 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 split into multiple for readability
- 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
Thank you so much for providing this guidance! I’ve been struggling trying to get the code correct to write a collection of people to a Sharepoint multiperson field and this was just the insight I needed to get it working. Thanks!
Hello Stalin, thank you for your post, I was wondering if you could help me sort out why my patch does not work:
I’ve essentially copied your example but am not using a people picker but rather a field lookup on another list. I cant figure out how to patch the colAllAssets collection to the field it was originally pulled from. I do not want to make a new list record, just update the column items from the Gallery.Selected.ID
Set(
assetToRemove,ThisItem.Id
);
ClearCollect(
colAllAssets,
ForAll(LoanGallery.Selected.Assets,
{
All: ThisRecord.Id
}
)
);
Remove(
colAllAssets,
Filter(colAllAssets, All = assetToRemove
)
);
Patch(‘Support Squadron – Asset Loan Tracker’,
LookUp(‘Support Squadron – Asset Loan Tracker’, ID = LoanGallery.Selected.ID),
{
Assets: colAllAssets
}
)