I am trying to toggle a custom state between ‘yes’ and ‘no’ in a workflow.
In step 1, if the state is ‘no’, change it to ‘yes’.
In step 2, if the state is ‘yes’, change it to ‘no’.
However, this always results in ‘no’. My current solution involves adding another custom state: when step 1 is triggered, it sets the state to ‘yes’, so step 2 is not executed. Then, in step 3, I set the additional custom state back to ‘no’. While this method works, it feels cumbersome.
What is the proper way to make toggling work? Is there any way to implement an IF-ELSE condition?
Just set up two workflows on that element and conditionally run one or the other on yes or no.
Is the simplest workaround for Bubble’s lack of inline conditional logic, just bear in mind that if you make lots of these and have many workflows, bubble won’t scroll to the workflow properly (or open one) when you click to edit workflows on the element.
It is possible to do this, but not by using two actions in the same event (trigger), since the last one will always be the final result. Instead you should have each action executed by an event and the conditional should be inserted at the event level. That way only one event would be executed.
However, for these cases, the best approach is to use double negation logic (or logical alternation in this case). So, in this case you use only one event, without conditionals, and the only action in this event should set the Custom State value by checking if “the boolean state of the element is no”.
This will result in:
1 - The current boolean state value is no? If it is not, it will be toggled to no.
OR
2 - The current boolean state value is no? If it is, it will be converted to yes.