The WHY:
The reason we customize a form is not only to give the end-user a better experience but because we are connecting to a data source and do not want to bother them with the technical details. When we are doing so, we need the form to be flexible in a way that doesn’t prepopulate forms unless we are explicitly choosing an option to be our default. Previously Power Apps prepopulated the default with the first option, and there were workarounds to this, but it wasn’t a clean solution to implement. The Allow Empty Selection, solves this problem, especially for when we utilize cascading dropdowns where the first drop down is crucial for showing the related options.
The HOW:
Once your app is open and a drop-down selection is chosen, whether it’s in a data card native to SharePoint or drop-down connected to a CDS, the result is the same. By default, the form leaves the AllowEmptySelection as false, meaning that it’s turned off and chooses the first item in your list to be the default which leaves us with the undesired outcome in this scenario.
NOTE: I’ve been asked if the Combo Box component has this feature because we oftentimes use the drop-down and combo box interchangeably, however, it does not have this feature at this time.
For this use case we will use a standalone card not connected to a native canvas form in order to walk-through the entire process and cover more of the edge cases.
- NOTE: If this is a new app this step is critical and this may be covered. ALWAYS start out by saving your application as soon as you open it. After the initial save, it autosaves every 2 minutes. Without this step, it will not save until you have done so manually thus internet outage or interruption could cause headaches. Yes, I have been there! 🙂
- Once the drop-down is added to the canvas, select it so that the control is active and showing the properties
- First, we will need to add a collection of items to the dropdown, erase “DropDownSample” and add copy and paste the following expression: [“Corporate”,”Branch”]
- This creates two choices, “Corporate” and “Branch”
- Link to Microsoft documentation regarding items dropdown choices, link here
- As you can see, the first choice by default is selected
- You can update the default by changing the Default property to another item within the expression
- At this stage, there is always a prepopulated defaulted selection
- Now when someone opens this form. They have already unknowingly made a selection because of this out of the box defaulted action. This has caused headaches in the past, especially when you are pulling these dropdowns from a list where there isn’t a blank option to default to.
- Ensure you have the dropdown selected and click the properties option and select AllowEmptySelection. Update this value from false to true.
- It is important that this is all lower case as Power Apps is case sensitive for true / false optoins
- Lastly, if you are still seeing a prepopulated defaulted option after updating the AllowEmptySelection value, save and refresh. This will reload the screen. Sometimes the functions get a little sticky, this being a notoriously sticky function.