cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
leomosqueira
Level: Powered On

!IsBlank() and !IsEmpty() for combo box

Hello, guys. I just don't know what to do anymore, so PLEASE, give me a hand or two, if possible...

 

I have a job to do to my boss. I creater a powerapps screen that saves data in a Sharepoint List, but one field of this screen, a combo box, receives data from the List to charge the choices available. 

 

So here we are:

 

tela 1.PNG

 

If I let any of the marked fields (*) blank and press "Save", it is supposed to appear an error screen:

tela 2.PNG

 

So If I fill the blank fields, everything's ok!

 

tela 3.PNG

 

BUUUUUT if I unmark, de-select the combobox previously selected item...

 

tela 4.PNG

 

It keeps saving the data of this page on my Sharepoint List, and without one of the mandatory values... Did you understand?

 

This is what I put on Save button:

 

If(
!IsBlank(Titulo_Novo.Text) && <- this is the first mandatory item
(!IsEmpty(Unidade_Departamento_Regiao_Novo.Selected.Value) Or <- this line...
!IsBlank(Unidade_Departamento_Regiao_Novo.Selected.Value) <- and this line were supposed to be working, checking if the field (combo box), which is the second mandatory item, is not empty or is not blank!
)
&&
!IsBlank(Objeto_Novo.Text) <- this one is the third mandatory item.
;
Set(Borda_TituloNovo; Black);;Set(Borda_UnidadeNovo; Black);;Set(Borda_ObjetoNovo; Black);;Set(Borda_ValorNovo;Black);; <- here I'm turning all the three mandatory items borders black.

UpdateContext({Popup_Salva_Item:true}) && UpdateContext({Fundo_CinzaNovo:true}); <- here I'm showing an pop up information message and a gray screen behind it.

UpdateContext({Popup_Alerta_Campos:true}) && UpdateContext({Fundo_CinzaNovo:true}) <- here I'm showing an pop up warning message and a gray screen behind it.
)

 

The warning message should pop up on the screen if any of the three mandatory itens were blank. 

 

Why the heck is that rule on the save button working for the combo box only if I select and item and de-select it? How should it be the correct way to write this rule?...

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: !IsBlank() and !IsEmpty() for combo box

Hi @leomosqueira,

FYI a Combobox contains a Table, even if it contains a single item or one column, so the appropriate function to test it would be IsEmpty() rather then IsBlank().  However, you can use IsBlank to test whether there is text in the Combobox's search property. 

IsBlank(ComboBox1.SearchText)

wil give a true/false result that can be used to change the Items property of a gallery or data table. I use this to remove the filter from a gallery using an UpdateContext() variable. 

If(IsBlank(Combobox2.SearchText),UpdateContext({itms: mydatasource}),
UpdateContext({itms:Filter(mydatasource,ID=Combobox.Selected.ID)})

and then set the Items property of a gallery to itms. That way if text is not typed into the Combobox, all the items in the gallery are shown or else the gallery is filtered on the Combobox.

2 REPLIES 2
Highlighted
AndySid
Level 8

Re: !IsBlank() and !IsEmpty() for combo box

If I understand you correctly, if there is no values in the ComboBox, or the values are removed from the ComboBox then show a message.

 

In this example I disable the save button but the method is the same.

The combobox Items are Units.Unit

 

Rule: IsEmpty(ComboBox1.SelectedItems.Unit)

 DisplayMode for Submit (generated by the rule)

If(Rule2, DisplayMode.Disabled
, DisplayMode.Edit
)

 

Does this help, if so please mark as a solution (:

 

 

 

Super User
Super User

Re: !IsBlank() and !IsEmpty() for combo box

Hi @leomosqueira,

FYI a Combobox contains a Table, even if it contains a single item or one column, so the appropriate function to test it would be IsEmpty() rather then IsBlank().  However, you can use IsBlank to test whether there is text in the Combobox's search property. 

IsBlank(ComboBox1.SearchText)

wil give a true/false result that can be used to change the Items property of a gallery or data table. I use this to remove the filter from a gallery using an UpdateContext() variable. 

If(IsBlank(Combobox2.SearchText),UpdateContext({itms: mydatasource}),
UpdateContext({itms:Filter(mydatasource,ID=Combobox.Selected.ID)})

and then set the Items property of a gallery to itms. That way if text is not typed into the Combobox, all the items in the gallery are shown or else the gallery is filtered on the Combobox.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, August 21st at 8am PDT

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

SixthImage

Power Summit Australia 2019

August 20-23rd 2019

Users Online
Currently online: 253 members 3,891 guests
Please welcome our newest community members: