Everyone loves the versatility of the combo box. PowerApps makes this control extra useful by providing the ability to “Search” through the results.
This post provides a method of clearing out the currently selected item in a combo box.
We found this to be a useful in cases where we are building UIs that capture data that need to be reset - for the creation of a new entry.
We tried to use the awesome Reset() function in our PowerApp to reset the value of a Combo Box control. The Reset() function will set the selected value to the first entry in the Combo Box - but it doesn’t clear it out, to preset the user with an “unfilled” control.
We have added a Combo Box to our design canvas. Here is how we set up the Combo Box:
The Allow multiple selections property is turned off
The Allow searching property is turned on
The Items property is set to an array of strings
["Active", "In Progress", "Cancelled", "Completed"]
We would like to see the following happen when a user clicks on the +New button in our app:
All of the controls in the data capture area of the UI should be reset, so that they are prepared for the entry of a new item
Here is how we built our solution.
Step 1: Capture the Reset Trigger
We set the variable didReset in the OnSelect event of the +New button:
Step 2: Set the DefaultSelectedItems Property
Set the DefaultSelectedItems property of the Combo Box control to evaluate the didReset variable.
If(didReset=true, [""], [selectedItem.SiteStatus])
This expression uses the If() function to evaluate the didReset variable.
If the didReset value it true, we set the property value to an empty string array item: [““]
This is a simple example of how to clear the selected items out of a Combo Box.
We hope it helps you with your PowerApps Canvas App. Happy building!