Is there a Boolean is empty condition?

Hi,

I use quite a lot of boolean variables in my app and use toggles to switch them on or off. However, in the beginning they are empty.
For my user, it’s important to see the difference between variable is ‘no’ and variable is empty. I want to use a condition for this, but the only conditions that are available are is ‘yes’ and is ‘no’.
I know that I can change all the variables to text types and use dropdowns, but I hope there is a quicker solution.

Thanks!

1 Like

Random brain-fart: what if you do a condition like:
[variable] is not "yes" AND [variable] is not "no"

Will that catch it?

I tried that already…when the variable is empty in the database the debugger gives for the condition ‘variable’ is no : Yes. So I think it interprets an empty value as no, which would be a huge bummer for me

1 Like

A boolean only has two states, on/off, yes/no, true/false. I’m afraid you are getting caught in the ‘oh, crap, why did I set it up like that?!’ position that every single one of us have been in :slight_smile:

1 Like

Exactly :joy: I could at least try to get out of it …

:laughing: It never hurts to try!

A Bubble boolean has three. True, False, Null.

And that is why we can get ourselves into quite a mess :slight_smile:

(not just bubble, but anything where you cam have null values).

2 Likes

It sort of does that internally, but if you format a boolean as text, then no (null no) comes out as blank. Although not empty it seems, which would have been a nice workaround.

1 Like

I stand corrected :smiley: I was under the impression Bubble treated null as False or, in other words, it was either True or Not True.

Is that Not True? :laughing:

:laughing:

I think it probably does but I just tied myself in knots trying to tell Bubble that if it is No as in Null and not No as in No then tell me it is empty :thinking:

And creating a list of No and Yes is much harder than I had imagined.

The problem is that you can’t design a condition with a boolean that has value null…

1 Like

… if there is a way I will let you know.

1 Like

I think it’s possible that because null is considered a Falsy value (http://adripofjavascript.com/blog/drips/truthy-and-falsy-values-in-javascript.html), depending on the way Bubble’s code evaluates the expression, empty values will return as No, as we’re seeing here.


Kevin
AirDev

We’re looking for Bubble developers to join our team: https://jobs.airdev.co/

Yes, it shows as ‘no’ in the debugger but won’t then translate if you try to evaluate as text or number.

Note that for at least two days, if you had defaults (like yes, no, nothing) when initializing your variables, then the value was null instead of Yes No. As Nigel @NigelG mentioned, it does not produce the expected result. So the best way is to say < > of “Yes”.

@kevin12, this seems very Truthy… :grinning:

1 Like

Since null is no, i solved my specific case by turning “show image” into “hide image” such that all pre-existing nulls are now no, and I can match for that as I wanted it by default, and only future items are set as yes will be hidden. Won’t solve every case.

I just introduced a “boolean” option set and set the related field to that type - now it can be “yes”, “no” or empty

1 Like