Hiding a component using multiple conditions
Last updated
Last updated
Sometimes you may want to use multiple conditions when setting conditional visibility for a component. An easy way to do this is to use logical operator formulas like AND()
, OR()
, and NOT()
.
In this example, I will use AND()
to make my purchases table visible only when the selected customer has a status of Active and true for Is Approved. If either of these conditions is not met, the purchases table will not be visible.
To set up conditional visibility using multiple conditions, start the same way as in other examples – click on the component you wish to make conditionally visible, then go to the Display section in the component menu.
In the Conditional Visibility field, first choose the logical operator formula that you want to use. In this example, that will be AND()
.
Next, enter the conditions that you want to use with the logical operator.
In this example, Is Approved is a checkbox – so it will already return True or False – but Status is a text field, so I will need to use the EQ()
formula to return True or False.choose the user property that you want to use. Because my property type is a checkbox, it already returns True
or False
based on its value.
When I have set this up correctly, the value in the Conditional Visibility field will be:
=AND(elements.Customers["0"].selected_item["Is Approved"], EQ(elements.Customers["0"].selected_item.status, "Active"))
Now the purchases table will only appear when a user is selected who is approved and also Active.
App builder view:
App view: