How to set visibility for a button

I have created an time off app for my employees, The problem i am facing is that my employees should provide me minimum a week notice before asking for long personal leave.

and for personal leave they should provide 1 day prior notice.

So. I just want to set the visibility of Done button after meeting above mentioned requirement.

Please help

Hi @Kash-1c06 two functions you can use in your formula to help with this is the OR() as well as the AND() functions. In the 'set visibility' area for your active blue 'done' button a formula like this could work:

OR(AND($[Leave Type]="Personal Leave",$[Start Date]-1>=TODAY()),AND($[Leave Type]="Long Personal Leave",$[Start Date]-7>=TODAY()),$[Leave Type]="Bereavement",$[Leave Type]="Family Leave",$[Leave Type]="Emergency Leave")

I abbreviated names and made some assumptions on what you named your variables, but a formula structured like that should work for you. The result of the formula should only show the active blue 'done' button if your user selects personal leave with the start date at least 1 day ahead of today's date, long personal leave with the start date at least 7 days ahead of today's date, or if they select any other leave type.

Then for your grey'd 'done' button you can make it the opposite by using the NOT() function so would be something like this:

NOT(OR(AND($[Leave Type]="Personal Leave",$[Start Date]-1>=TODAY()),AND($[Leave Type]="Long Personal Leave",$[Start Date]-7>=TODAY()),$[Leave Type]="Bereavement",$[Leave Type]="Family Leave",$[Leave Type]="Emergency Leave"))

There may be a different formula you could use to accomplish what you are looking for, but I believe using the OR() AND() function combos should work. If others have ideas on a different formula, I'd love to know. I'm always looking to learn about new ways to write formulas :nerd_face:

1 Like

Hi @Kash-1c06, thanks for your question here!

Great answer from @Milly too! :star2: I just have a couple other notes that may be helpful.

We have an article on conditional visibility that shows you how to set up data validation to either show a clickable button or a greyed-out button: Add Conditional Visibility & Data Validation.

For your formula, the object will be visible if the formula returns true. So breaking down Milly's formulas, you can see how each piece meets your asks criteria. You can check out this article as well with more info on the different functions: Honeycode Functions.

Let us know if we can help any further. :slight_smile:

1 Like

This is not working

Input an equals sign at the start of your formula so that your visibility setting understands your formula will evaluate to a result. That should clear the error you are seeing.

Tried it but the result is same

I took a look at your formula again and it looks like you are missing closed parentheses for your OR function. I count 11 open parentheses and 10 closed. Input a closed parentheses at the end of your formula to close out the OR.

One tip that I use when troubleshooting longer formulas is to break it out into parts and test each part to see what errors out (ie. testing each AND function and adding other working AND functions to it). I repeat testing sections of my formula and adding to it until I land on my end formula I want. Hope that helps for any formula troubleshooting you may encounter in the future :slight_smile:

1 Like