I have 12 checkboxes each with a trait associated with them. I'd like to program their OnCheck so that when each is clicked, the associated trait is added to a collection. There will be a later button which adds the list of selected traits to a SharePoint List, and this button is programmed, but I can't get the checkbox/collection to work right.
I additionally would like to program the OnUncheck to remove from the collection.
For OnCheck, I tried:
Collect(CBI_DR_PosCol, CBI_DR_Positive_1.Value)
This only adds "true" to the collection though. I tried replacing .Value with .Text, but this was an error.
EDIT: The error reads: "The function 'Collect' has some invalid arguments."
For OnUncheck, I tried:
RemoveIf(CBI_DR_PosCol, "Trait1" = CBI_DR_Positive_1.Text)
and this seemed to work.
Based on the comments and the edited question:
To store traits in a Choice field for each candidate (row), you should represent traits in Power Apps like records: { Value: "Trait1" }
. This is something that SharePoint accepts and you can use the collection's .Value property in the checkboxes.
If the checkboxes are in a gallery, .Text should be ThisItem.Value
The formulas need to be updated too:
Collect(CBI_DR_PosCol, { Value: Self.Value })
RemoveIf(CBI_DR_PosCol, Value = Self.Text)