Hi All,
Is there a way to make sure a valid selection is chosen in a combo box?
Here is my situation...
I added a combo box to my gallery, set my choices() and all is working wonderfully, until I let a user try it 🙂
When you click the arrow in the combo box I get my choices, if I start typing "001" the only value with "001-EPF" shows up below where I am typing, if you click away thinking the value is in the dropdown, you only get "001" not the full value "001-EPF".
When I patch the value 001 is not saved since it is not a valid choice, and brings back a blank line.
Is there a way to force the full value?
When there are multiple items you need to make a choice, but when there is only one, I need it to populate fully.
TIA,
Joe
My requirements are same as yours! However, I am not able to understand solution for this! Could you please elaborate on solution!
My Apologies but I am new to Power App and hence probably not able to follow everything!
Thanks for your help and support!
Hi @JR-BejeweledOne , @RandyHayes ,
I used a combo of both. I check for empty and on select of the ComboBox, I Set a Var to true. (OnChange I set it back. Since in my world OnChange only happens when an item is selected this works perfectly :))..
The warning visibility is only when both are true.
Thanks again both!!!
Joe
While I agree with Randy that not using variables when not needed is a great idea, you may need to in this instance.
Randy may have a better idea.
Thanks again both @RandyHayes and @JR-BejeweledOne ,
Funny I can't use the IsBlank() in the "OnChange" event but I can in the warning text box.
The warning pops up, and I can't get rid of the warning without choosing an item, perfect 🙂
But If I delete the empty row from my gallery, the warning stays there, is there a way to reference the visibility?
I would add it to the delete button to hide the Warning.
My app has an add button that patches a new row to the list with a blank location for my gallery, the warning pops up (OK)
You choose an item the warning goes away! (great)
I Patch another new row to my list (warning pops up Great!) , but I decide I didn't want to add the new row, so I delete the row, the Warning is still there until I choose another dropdown from the gallery, or add another row and populate it.
Same thing happens if I just delete a row from my gallery, until I choose another.
TIA,
Joe
What I provided should give you what you need for automatically selecting an item if the search returns only one item.
What you are referring to is validation of the control. In which case you need to simply validate that the control has a selected item prior to allowing to submit.
Why set a variable?? Avoid the variable!! Simply reference the control in your submit - CountRows(ComboBoxX.SelectedItems)=0 means there is nothing selected - this applies to multi-select. For single select combos, you can simply validate with IsBlank(ComboBoxX.Selected.xxxxx) where xxxxx is a column in your items records.
So, for your warning label, just set the visible to: IsBlank(ComboBoxX.Selected.xxxx)
Did you try my suggestion? Again I tested it and you are going to have to build some logic that will prevent them from submitting if there is no value.
In the OnChange property of your combobox, set a formula like this:
If(IsBlank(ComboBoxX.SelectedItems), Set(varSelected, false), true)
Then have a warning label to become visible if varSelected is true, you can also set other controls display mode to view as long as the variable is false which will prevent them from continuing until they select an item.
Your warning can tell them they need to select an item in the box before they can proceed.
Hi @JR-BejeweledOne ,
Typing into the combo box without choosing an item does not fire off the "OnChange" event.
I placed your code into the OnChange, if I type 00 then click on the next column, nothing happens.
If I choose an item my Var goes to true and my popup shows up.
I wanted to go with @RandyHayes solution, but a bad value is just as bad as an empty value.
I can't allow them to save the item unless there is a value in the combobox....
I can't be the only one with this issue... (or am I?)
I tested this before replying. It works very well. Typing into the box isn't the same as actually selecting an item.
As you have noticed, the selection must be made after typing in the search.
There is no way to force the combobox to do what you want...HOWEVER, there is a work around!
Place a toggle control (let's call it tglOneItem) on your screen and set its Visible property to : false
Set the Default property of tglOneItem to :
CountRows(Search(yourComboboxItems, yourComboboxName.SearchText, "yourSearchColumn")) =1
Set the OnCheck action to:
UpdateContext({lclSel: First(Search(yourComboboxItems, yourComboboxName.SearchText, "yourSearchColumn"))})
Set the DefaultSelectedItems property of your combobox to: lclSel
This will give you what you want. Note: you'll want to UpdateContext({lclSel:Blank()}) somewhere like when the screen is visible to clear that selection - don't try to put it in the OnUncheck action of the toggle as that toggle fires very quickly from checked to unchecked and will clear what you just set.
Notice in the below animation, I type "Item 2" and nothing else is clicked or pressed...the combobox will automatically select the One item that is based on that search.
I hope this is helpful for you.
The issue is that when you start to type the characters are entered into the box, so when you click away, there is a value in the box. That was my first thought...
WarrenBelz
146,743
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,083
Most Valuable Professional