Skip to main content
All CollectionsBubble FeaturesQuick Tips
Understanding Workflow Execution Rules
Understanding Workflow Execution Rules
Updated over 3 weeks ago

Transcript

In this Quick Tip, we're going to learn some general rules about executing workflows! We build our workflows using a linear sequence of actions, beginning with Step 1, Step 2, and so on. However, because Bubble prioritizes the most efficient order of execution, actions in a linear sequence may not be completed in the same order as they are triggered.

For example, with frontend workflows (any workflow contained to a specific page), an action will not wait for a previous action to complete before it triggers. So let's say Step 1 of my workflow here creates a new thing. Later, I want Step 3 of my workflow to perform a search of my database to try and retrieve that new thing. However, searches are not always instantly up to date with the database, so we may be executing Step 3 before Step 1 has had an opportunity to complete. So this search may or may not turn up the new thing.

If you want to be absolutely sure that Bubble will execute your actions in a specific order, you will want to retrieve the new thing using the "Result of..." expression, as seen here. By referencing the result of step x in step y, we can ensure that step x will be executed first!


With custom events and backend workflows, the rules of execution change in the following ways. Custom events run sequentially within the workflows that trigger them. If you trigger a custom event in Step 2 of your workflow, all remaining actions will wait until the entire custom event workflow is completed before triggering.

On the other hand, if you have a workflow step that triggers a backend workflow, Bubble will automatically trigger that backend workflow as soon as this workflow is triggered, even if the actual step is at the end of the sequence.

Again, this is how Bubble maintains efficiency by default, but if you really wanted to ensure a backend workflow was triggered at a specific point, we can put two and two together: if custom events trigger wherever they are in the sequence but backend workflows trigger immediately regardless of the sequence, we can contain a backend workflow inside a custom event. The backend workflow would then wait to trigger until the custom event that contains it is triggered, thus controlling when it is executed in the sequence.

To recap, actions in your frontend workflows may trigger in sequence but be completed out of order. And backend workflows will fire as soon as your workflow starts no matter where the trigger is in the sequence. However, when needed, you can use custom events and the "Result of..." expression to ensure that your workflows are executed in a specific order.

That's it for this Quick Tip! For more, be sure to check out bubble.io/academy.

Did this answer your question?