OR conditional rules for visibility

Hello,

I’m wondering if anyone has thoughts on easily implementing “OR” logic on visibility rules for components. Stacking layers does a fine job of creating “AND” functionality, but what about if you want something to be visible if one of multiple conditions are met?

I asked this question in a different, old thread but it sort of fizzled. Lots of explanation and thoughts there: Setting visibility based on multiple parameters

I figured that this topic deserves it’s own thread anyway, so here it is. Hopefully we’ll have better luck getting some responses and ideas!

Thanks in advance.

1 Like

Hi @tbtilton ,

Take a look at this post,

AND is derived from count relation=count preference
OR is derived from count relation>0

If you want to have OR AND in action conditional, search for Binary Total, it is a proxy variable that we need to update first, so we can use them in single expression conditional.

1 Like

Thanks for the input!

I had explored that as an option. Not super practical for me, as I have more than 2 possibilities to choose from.

HOWEVER, revisiting the concept gave me a new idea that I hadn’t considered up to this point. I use “hidden” text inputs a lot to control visibility and inputs, and I realized I could use the same idea to accomplish “Or” visibility logic:

I create a text input, call it “ShowButtons”. Set the default value to 0, and make it all transparent and small so the user can’t see it.

I create my conditionally visible button, and set the visibilty to sometimes visible, when “ShowButtons” = 1

Then, I use the the screen onLoad actions to set the “ShowButtons” variable, using the “Change Input Value” Action, which have their own “sometimes” logic.

I create an action to Change Input Value of “ShowButtons” to 1, then set it so it only happens if one of my conditions is met. I can stack as many of these actions as I want - each one set to make the “ShowButtons” input to 1 IF it’s specific condition is met.

Now, when the screen loads, it will run through the conditional actions, and if ANY of them are met, it will set the “ShowButtons” input to 1, and the Button will display!

Best part is it’s dead simple AND doesn’t clutter up my collections. Problem SOLVED.

Thank you. I appreciate your reply as it led to my brainstorming of this solution :grin: :+1:

Hi @tbtilton ,

The AND that you mention can also be achieved using groups, make group as many as required and they are all checked using AND.

But that cannot be used to AND the relationship field, it needs help of count and filter to do that.

But if it works then great things happened here. :smiley:

1 Like

can you explain this group solution a little more?

I want to be able to filter based on open, closed, and all.
My documents have a status of open or closed so I can filter for those, but when I want to see everything in the list the filter doesn’t work any longer

Hi @aaronksaunders ,

With new OR filter, we can have better way,

Look at this cloneable app,

I guess what you are looking for is OR expression.

thanks for sending this over, but i have absolutely no idea what is going on in this app you sent me so it is of no real use to me without an explanation

No code platform like Adalo is supposed to be self explanatory, we do that by inspecting components involved.

In this case, you can check about the filter in custom list, it is already using the new OR feature.

And buttons do an action to change the input value.

In database collection you can see their relationship by finding the relation field and see their status’s name.

You can change their status and see what happens.

1 Like

there are very few things that are “self explanatory” and IMHO this isn’t one of them

  • there are multiple filters
  • there is a hidden field
  • there is toggling between the all and the filter button

Thanks for the effort, it is a bit clearer with your explanation - I’ll keep digging.

1 Like

Hi @tbtilton,

If we’re talking about “generic” OR logic for some abstract component, then I’m afraid that there is no straightforward way to do it. The only option is creating a conditionally visible component for each case.
E.g. if you have a button and you’d like to display it when Logged-in User → Color is Blue, Red or Orange, you will need to create 3 buttons for each case.

However in some particular cases you can optimise this. E.g. for the lists there is already an OR filter (so you can have less lists on a screen).
Also you may try to find another property in common for all cases with the same OR condition. E.g. if you’d like to display the button when Logged-in User → Color is Black, Grey or White, you can have an additional property “colortype”, for Black, Grey or White it will contain “achromatic”, and then you use this property.
Using “contains” instead of “is equal to” also may be useful in some cases.
In other cases you can try to use numeric properties as a filter base: e.g. if you have a workflow with 5 stages, and you’d like to show some button only for stages 2 and 3, you can use “Stage ID” is between 1.9 and 3.1.

These all are workarounds though, as a fundamental functionality is missing.

Hope this helps.

Best,
Victor.

2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.