Boolean Database Triggers

I’ve created a database trigger for when a boolean value changes. Unlike all other fields, boolean fields don’t allow the following expression:
{datatype} Before Change’s {boolean field} IS NOT {datatype} Now’s {boolean field}

To overcome this, I was able to write the expression out using the the “yes” and “no” selectors as:
before change’s bool is “yes” and now’s bool is “no” OR before change’s bool is “no” and now’s bool is “yes”

image

It doesn’t work though. A workaround is going to be to change the field to text and just use the boolean everywhere as text, but I rather not. I rather figure out how to make the DB trigger off the changing boolean value in the datatype.

UPDATE: I’ve tested that the trigger works for “no” to “yes”. It IS NOT working for “yes” to “no”

UPDATE2: I broke out the condition into it’s own trigger and now it works. Who knows why I can’t “OR” these together into one condition? This is definitely a Bubble Engineer question.

Hello!

First of all, i think you are using the operators wrong, the first AND: 'PatientApp… before change FileWith… is “yes” AND PatientApp… before change FileWith… is “no” ', is checking if the condition is no and at the same time is yes (a schrodinger effect :sweat_smile:).
That could be solved putting one condition in 2 different triggers (one triggers when field before is ‘yes’ and now ‘no’ || another triggers when ‘no’ and now ‘yes’) edit: just read you updated it with this .

I think that maybe you can check if it changes from before to now negating the expression:
“” When PatientAppDetails Before Change FileWithState…YN is not PatientAppDetails now FileWithState…YN “”
and you can use only one trigger (it translates as “when current field isn’t the same as previous field, trigger it”)

Hi @tgmoron ,
First off, thank you for chiming in. Please give your proposed solution a try. You’ll find your solution isn’t a selectable option. That, or I’m doing something completely wrong that is causing my context menu of options to not show all available options. This is my problem… I tried to do your solution because that’s how it works with every non-boolean field. Unfortunately, boolean fields have to have their individual expressions written out in long form and for both directions, since you can’t compare the field, you have to compare the individual values.

1 Like

You can format it as a text! so it compares between the ‘‘yes’’ and ‘‘no’’ as strings

image

Little example:

Data structure

example

1 Like

alternatively you can compare them as numbers 1/0

image

1 Like