Handling Conditionality

Very often, you will find yourself in situation where a workflow should only run under specific circumstances. For instance, process an order and charge a credit card only if the current user is logged in, or only process a sign up flow if the user checked a box agreeing to some terms. To enable you to do this, Bubble offers the option to define some conditions on events and actions.

Event conditions

A condition can be applied at the event level. In this case, when a condition is evaluated to no, the workflow won't run, while if it's evaluated to yes, it will run. If an event does not have a condition, it will run all the time.

You can define such a condition using the Expression Composer, similarly to what you do for elements' conditional settings. Note that the condition must evaluate to a yes/no expression, and if it does not it will be reported as an issue by the issue checker and should be fixed before you run your app in run mode.

You will often have to debug events with conditions to understand why, in run-mode, some events are running and some others are not. We recommend using the debugger in step-by-step mode to understand which condition is evaluated to true and how it impacts the workflows. See the Using the Debugger section in the [Testing an Application](/testing-an-application.md) chapter in the manual for more details.

Actions conditions

If you need more granularity in your conditions, you can add conditions to a particular action in a workflow. The Expression Composer will be similar to event conditions, and you can define an expressions that evaluates to yes/no. If the condition evaluates to yes, or if there are not condition, the action will run, while if the condition is evaluated to no, it will be skipped.

Note that if a following action is using the result of an action that is skipped, the Result of Previous action will be empty. This is your responsibility as a app builder to make sure you do not introduce issues in your app using conditions on actions. Here again, using the debugger in run mode is a very good way to debug issues.

results matching ""

    No results matching ""