I have an App where I am populating a collection with all matching items based on the selection in a combobox. There are 2 options in the ComboBox and the user can choose one or both. The collection is populated with the matching items for the selections made in the ComboBox.
Disclaimer: I have this working beautifully! I am NOT looking for solutions on how to accomplish the above.
What I need however are suggestions on how to trigger the removal of the same matching items if an item is deselected in the combobox.
I know how to do the removeif to remove all the matching items. What I am having trouble figuring out is how to determine that one of the selections has been removed from the combobox so I can then remove the items from the collection.
I have looked at a few different options, but because of the way the combobox works, all seem to be problematic.
Here an example of what I need to do:
ComboBox Items = European Union and North America
When one is selected, all the matching items are added to the collection. If the other one is then selected then all those matching items are added to the collection. So the collection can contain items that match one or both choices.
If I remove European Union from the ComboBox I need to remove all the matching European Union items from the collection and if I remove North America from the ComboBox I need to remove all the matching North America items from the collection.
I suspect it's going to have to be some complicated solution with comparing values in variables or something like that.
All suggestions are welcome. I miss the InfoPath mult-select checkbox control. 😞
I am not sure how the collection is being used, so this might not be a work in your case. You use the OnChange property of the Combo box to do a ClearCollect() and basically reset the collection based on the items selected in the Combo box.
You would think that it would be that easy but it's not. Full scenario, this is a mock 'repeating table' scenario.
Here is the behavior I have found regardless of which one I select first.
When I select European Union all 28 associated countries are added to the collection, then when I select North America, 2 additional countries are added. So now I have 36 entries in my collection.
Because of the way the selected item value works in the combobox, if I remove North America, then the value is European Union again and those 34 countries are added a second time to my collection giving me 70 items in my collection and vice versa.
If I use ClearCollect, then each time a new selection is made from my combobox, it erases the previously selected items.
The point of the combobox in my app is to be able to select multiple items and each time add to the collection, not change it.
Check out the News & Announcements to learn more.
Did you know that you can visit the Power Query Forum in Power BI and now Power Apps
Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.
Check out our new Discover Your Career Path blog post series and get all the details.