This article is a proposal of how to edit a multiple selection Person field from a Power Apps customized form, using a gallery control.
We have a list with a Person field that is allowing multiple selections. Fields are Title and Users.
Depending on how many users are recorded into the field we can have issues to edit/update the list of users. The control of multiple persons cannot be resized to edit/update easier members from the field (or I do not discover a way to do it).
Editing a multiple selection Person field. Combo control for Person field is renamed to cboUsers.
In this article I am proposing a way to edit members from Person field using a gallery control.
To achieve this, insert a button, in my case called Edit, that is creating a collection based on Person field and set a variable to value 1. Code for OnSelect property of the button.
ClearCollect(cUsers, cboUsers.SelectedItems); Set(varDisp, 1)
Next step is to create a gallery. Items for gallery is cUsers collection. Better option is to use sorting for Items:
SortByColumns(cUsers, "DisplayName", SortOrder.Ascending)
For Visible property of the gallery, I use:
If(varDisp=1, true, false)
My form when click on Edit button:
Next step is to change the icon into Trash and add following code to the OnSelect property of Trash icon:
Remove(
cUsers,
ThisItem
);
ForAll(
cUsers, // Current collection
Patch(
MultiUser, // Main data source, name of list from SPO
LookUp(
MultiUser,
Title = txtTitle.Text // Identify the current record into the list.
),
{Utilizatori: cUsers} // Utilizatori is the name of the Person field from list.
)
)
Formula for OnSelect property of Trash icon.
If you receive any error messages like: Title is required, verify if you properly close LookUp function.
Disadvantages of this method is related to speed of deleting items from Gallery related to time for Patching into the list. If you delete faster items, you can receive an error message: Network error when using Patch function. The request operation is invalid.
Even the message appear I was able to delete entire persons from gallery.
Hope you find useful this article!
Lasă un răspuns