cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Axal
Super User
Super User

Is "IsEmpty" for combobox need "selected.value" ?

Hi guys,

 

I am confuse on how to validate drop down control. I have a dropdown (combobox) in my form, that I want to validate if it is empty.

Many thread explain to give like this "IsEmpty(cbCompany.SelectedItems.Value) or using "Selected.Value"

 

Which one actually we should use ? and also I tried both, but when I want to add ".value", it does not appear in suggested options in formula box, it even give "red wave line" informed me that it is error formula.

 

How is actually to validate a combo box ? while actually I would also want to negate it, as if " If not", I assumed I can use exclamation sign in front, is it not?

 

Thanks

9 REPLIES 9
zmansuri
Super User
Super User

Not Value. Always SelectedItems worked for me

Sometimes it works with

IsEmpty(Combobox.SelectedItems) sometimes IsBlank(ComboBox.SelectedItems)

WarrenBelz
Super User
Super User

@Axal ,

You can use 

IsBlank(cbCompany.Selected.Value)

or

Len(cbCompany.Selected.Value)=0

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

KvB1
Solution Sage
Solution Sage

 

IsEmpty(ComboBox1.SelectedItems)

 

Should return 'true' if its empty, 'false' if its not. The argument for a combobox is different than for a dropdown, so maybe thats where the confusion comes from. 

 

To 'negate' you can just add a Not( statement, as well as a !, for example:

 

Not(IsEmpty(ComboBox.SelectedItems))

 

Will return false if the ComboBox is empty and true if its not

WarrenBelz
Super User
Super User

@Axal ,

Adding to my previous response, the reason .Value may not work depends on the Items of the combo box. Please read towards the bottom of the section of my blog on Controls and their references.

It could be .Result (for a Distinct filter) of .FieldName (actual field name) if displaying a field value.

SelectedItems normally refers to multiple selections, however to properly test if a combo box is empty, you might try one of the options I posted, but replace .Value with the proper output as above.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Hi all,

 

Forgive me but I still confuse which actually I should use. Basically I have these object (control type) in my form:

- ComboBox (a lookup)

- Text (

 

I tried to use IsEmpty(combobox.Selected.'my field'), because it didn't work, I tried IsEmpty(combobox.SelectedItems.'my field'). Both is not working

 

And I actually want to have the condition to check if it is not empty, I will have to Set variable to True. Like this one ->

If (Not(IsEmpty(DataCardOrderValue.Selected.'Planned Order')) && Not(IsEmpty(DataCardCategoryValue.Selected.'Category ID')) && Not(IsBlank(DataCardDescValue.Text)) && Not(IsBlank(DataCardQtyValue.Text)) && Not(IsBlank(DataCardPriceValue.Text)), 
    Set(ValidRequiredFields, true),
    Set(ValidRequiredFields, false)
);

 

So with those 2 control type, I have 5 controls and all of it I want to check, all should have value, if there is one field not filled in, my flag will indicate "not valid" (ValidRequiredField = false)

 

Am I correct to create such formula ? 

Please help.

Thanks

 

 

@Axal 

What are the Items of ComboBox1?

Hi @WarrenBelz 

 

The item of the combo box is Choices from the data source, something like this :

Choices([@'Order Details'].xyz_PlannedOrder)

 

Having a look from your blog, guess should be IsBlank(DataCardORderValue.Selected.'Planned Order' I supposed ? the 'Planned order' is the name  (label) of the field while the field itself is 'xyz_PlannedOrder'

 

But that didn't catch, also when I changed to use IsEmpty.  

 

Thanks

@Axal ,

If the Items of ComboBox1 are 

Choices([@'Order Details'].xyz_PlannedOrder)

as you have stated, then the valid output is 

ComboBox1.Selected.Value

and the validation if it is blank/empty is 

IsBlank(ComboBox1.Selected.Value)

or 

Len(ComboBox1.Selected.Value) = 0

You can also head down the track of

IsEmpty(ComboBox1.SelectedItems)

but I have found this to be not always reliable, hence I always use the Len() syntax.

Please put a label on the screen and type in

ComboBox1.Selected.

(note second dot) and see what values come up underneath.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

WarrenBelz
Super User
Super User

Hi @Axal ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (2,853)