Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Disable button if condition not met for all textboxes



I am trying to provide a sign-off capability for my managers so that they can provide a sign off in one click for all the items that fall under their purview. The entry of the data in the textboxes is based on multiple conditions and if any condition fails, it provides an error message for that item. Now the Managers should only be able to provide a sign-off if all the items are error free i.e. the error box is empty/blank. 


Currently, the managers are able to click on the button even is one error box is blank while others may still have errors. And the sign-off is flagged as yes for all the items under them. I want that the button should be disabled, until and unless the errors from all the items are removed or taken care of. 


The formula I am using is : If(
!IsBlank(DatePicker.SelectedDate) && IsBlank(ErrorMsglbl.Text) && !IsBlank(Input_comments.Text) && !IsBlank(Dropdown.Selected.Value),UpdateIf('New Projects',User().Email in 'GM email id',{'Sign off status': "Yes"}),Notify("The data is invalid to sign-off on the projects",NotificationType.Error))


Please provide some guidance/help on this matter. What can I change in the formula?


Accepted Solutions
Super User
Super User

What if you try:


button.visibility = If(CountRows(Filter(YourGalleryName.AllItems, !IsBlank(ErrorMsglbl.Text)))>0, false, true);

this will ensure that all items in the gallery have no error message.

If need to check other fields along the way, just add extra filtering options.



View solution in original post

Advocate II
Advocate II

Hi @tapastiwari


One way to achieve this would be to make your sign off button invisible until all the conditions are met.  So in the Visible property of the button, put a similar If statement to the one you have written: 

If( !IsBlank(DatePicker.SelectedDate)

&& IsBlank(ErrorMsglbl.Text)

&& !IsBlank(Input_comments.Text)

&& !IsBlank(Dropdown.Selected.Value, true, false)


So the sign off button will only be visible if there is a Date, no Error Message, a Comment and a choice from your Dropdown.  

Hi @LooseChippings


Thanks for your help! 


The button becomes visible even if the error is cleared from one item, and the manager is then able to sign-off on all, including the ones with errors. Is there a way we can limit the visibility of the button, so that it becomes visible only after all the items are clear of the error message? 




Hi @tapastiwari 


Yes, there is.  With an If statement, you can use '&&' or you can use '||'.  && means 'AND' , (so Red && Green means "red AND green") .  || means 'OR', (so "red OR green"). 


It is sometimes confusing to get the right logic when using AND/OR, but in your case, changing the && to || means the button will remain invisible "If the Date Picker is blank OR the Error Message has text, OR the Comments are blank OR the Dropdown is not selected", which is what I think you need.


The symbol '|' is called a Pipe and is found by pressing [Shift \].

I think Tapas is referring to list of gallery items @LooseChippings instead of 1 single item. Is there a way to implement it for a list of items in gallery?



Hi @vaibhavtandon87 


Yes, you can add a button to a gallery and use the same principal of a series conditions inside the IF statement. The main difference will be the reference to the input fields.  So Tapas' case, the reference would be something like:

If( !IsBlank(ThisItem.DatePicker.SelectedDate)

|| IsBlank(ThisItem.ErrorMsglbl.Text)

|| !IsBlank(ThisItem.Input_comments.Text)

|| !IsBlank(ThisItem.Dropdown.Selected.Value, true, false)


You may (almost certainly) only want the button to show up on the selected row of the gallery.  In this case add an extra condition to the Visible property of the button:
If( ThisItem.IsSelected,
&& !IsBlank(ThisItem.DatePicker.SelectedDate)

|| IsBlank(ThisItem.ErrorMsglbl.Text)

|| !IsBlank(ThisItem.Input_comments.Text)

|| !IsBlank(ThisItem.Dropdown.Selected.Value, true, false)

Thanks for the reply!


@LooseChippings One button to be only 'enabled and be able to save' 'all' the items when all the 'conditions' are met. Else even if 1 row out of 10 etc rows in the gallery dont meet the criteria then button should not be enabled.


Currently the button only works successfully for first item when the criteria is not met else it gets enabled.

For clarification - I and him are working on the same problem statement

Hi @vaibhavtandon87 & @tapastiwari ,


Can you please place the formula provided by @LooseChippings as a text property of a label and see the results? Share the screenshot on what you see when using the formula provided by @LooseChippings .

Hi @vaibhavtandon87 


So, you have a gallery with many rows (say 20).  What I have suggested should show a button only in the selected row if all the conditions are met in that row.  After re-reading the original post, I think you are asking for one button to submit all the rows where the conditions are being met.


A basic PowerApp is normally set up to have a Gallery showing many items.  You select an item and it populates a Form with the details of the item.  There would then be a button on the form to submit the form back to the data source.


What you would like is possible but rather complicated.  You could have a button not in the gallery and use a ForAll() and Patch() statement, with the If() statement, in order to run through all the items in the gallery which meet your criteria.  There is a Shane Young @Shanescows video here which covers this subject.


Helpful resources

Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,449)