How to handle a lot of "or" with "and" expressions in conditionals?

Hello, community,

I want to share with you a tip that might help you in the future or current projects.

For instance, you have a lot of conditionals tied to or:
When value is 1 or value is 2 or value is 10 or value is 90 or value is 10320123.

Then, you got a new requirement to update the conditional that it should be available for an admin user type.
Instead of writing:
When user is admin and value is 1 or user is admin and value is 2 or user is admin and value is 10 or user is admin and value is 90 or user is admin and value is 10320123

As an idea, you can use the following expression:
Current date/time is not empty: formatted as text is yes and user is an admin

Inside of the formatted as text you need to set the following expression:
value is 1 or value is 2 or value is 10 or value is 90 or value is 10320123

Take a look at one of the examples, please:

Editor:

I hope you find this useful.

9 Likes

I will start to use it instead of ‘If Development’ :slight_smile:
Will be great to share in Bubble doc.

2 Likes

Thank you @lottemint.md

1 Like

Very useful! Thanks for sharing, @lottemint.md! :slight_smile:

1 Like

Hello,

There is a little update regarding this tip.
We noticed that the initial example doesn’t work for multi-language apps.
In short, “yes” (English) is “tak” (Polish). Your condition fails because you hardcoded the “yes” value.

The following solution solves that problem:

  • Instead of contains yes, you set contains 1
  • Instead of contains no, you set contains 0

Let me know if you have any questions, please.

2 Likes