How to combine AND and OR operators?

I’m trying to setup a “Only when” condition like the following. How would I do this? Do parentheses work?

Search for Emails:first item's name is empty AND (Result of Step 3 is empty OR Result of Step 3 is not empty)

2 Likes

Parens do not work. The part you have in parens in your example is always true of course, so it’s not a necessary condition. It’s superfluous.

It boils down to:

Bool or not(Bool)

Which will always only have one state:

Yes OR No (which equals Yes)
No or Yes (which equals Yes)

So, the expression you want is just that the search result is not empty.

Based on past discussions in the forum it’s necessary, because I only want the next step to run (which is using the above “only when”) after Step 3.

The first bit “name” doesn’t look like a yes/no (true/false) field, you’re probably missing something like “name isn’t empty”.

Bubble’s way of combining AND and OR is left to right, which is different from most programming conventions.

If you are using a javascript or node expression, you can use parentheses , AND is &&, OR is ||

You’re correct about the “is empty”. I added it to the example.

So even though I don’t have parentheses, the specific example is almost like it does have them?

AH! Gotcha (indeed, you would want to to force evaluation of step 3’s state).

So I believe the correct order is:

Bool3 OR Bool2 AND Bool1

Which evaluates like:

Yes And Bool1

@keith got it : )

FYI Keith was pointing out that (X OR NOT X) is pointless.

Right. And then @Kfawcett pointed out that he’s just forcing evaluation of step 3’s empty state to enforce synchronous behavior.

Oh I completely missed that post, while I was typing LOL

FYI the order goes left to right, so taking it from the top …

(Search for Emails:first item's name is empty AND Result of Step 3 is empty) OR Result of Step 3 is not empty

Which isn’t great … you can reorder things …

(Result of Step 3 is empty OR Result of Step 3 is not empty) AND Search for Emails:first item's name is empty

The synching reference would be for a page workflow, to synch the server and client workflows together?

3 Likes

Thanks @keith and @mishav! Go go team bubblers! :wink:

1 Like

I guess another way to describe this to less experienced users is:

Chained Boolean expressions are evaluated from left to right. The leftmost pair of arguments is evaluated first and the result of that comparison is used in the next comparison until we reach the end of the Boolean expression.

By way of example: Bool1 is yes. Bool2 is no. Bool3 is Yes. Bool4 is No. Bool5 is Yes. Bool6 is no.

Expression:

Bool1 or Bool2 and Bool3 and Bool4 or Bool5 and Bool6

… will evaluate like this:

Yes and Bool3 and Bool4 or Bool5 and Bool6
Yes and Bool4 or Bool5 and Bool6
No or Bool5 and Bool6
Yes and Bool6
No

7 Likes

This topic was automatically closed after 70 days. New replies are no longer allowed.