Steps execution order within a workflow event


I’ve seen this in other posts, and also read in bubble documentation, yet still running into issues.

Is it true that a step down the line of a workflow event could run before other steps, and the debugger will not land on it?

Here’s the scenario:
User presses a button which checks if data they just entered exists.

Step 1 triggers a custom event that checks the database for the a record with the number they entered and a specific status, let’s call it A.
Step 2 triggers a custom event if the record is not in status A.
Step 3 triggers a custom event if the record is in status A, and then makes changes to the thing to status B.

What happens in actual life is that the “Make changes to a thing” step in the event triggered in step 3 of the parent event runs before anything else without a trace in the debugger, and when the workflow hits step 2 the record is already in status B, which causes it to trigger.

I put every step into a triggered event as I understood from bubble’s documents that triggered events from an event do in fact run synchronously.

I try to run the debugger to trace the problem, but frustratingly I see the database change but the debugger runs synchronously.

I ended up using a 1 second pause in event in step 1, and a state that updates only when that step is complete, and that stops this kind of behavior. But this seems risky to me as the search could take longer than a second at a very busy time. Suspending for more than a second could result in a not so friendly UX.

Is this a known bug, or am I missing something?

Thanks in advance for any further light on this matter.

Hello @bamapt

Yes. Bubble runs actions in parallel where possible always. Using custom events to achieve a truly chain-like process may be more of an art given what you described. Without seeing the specifics it is difficult to provide specific advice.

As a first pass …. Try using “result of” as much as possible and trigger chained logic … as a chain.

Hope the above makes some sense

Also this post may help:

Thank you, Carlos @cmarchan

From my experience “result of” works only if the action is an api call or a creation of a thing. Here I don’t create a thing, only query the database.

Additionally in the post you linked to it says that using custom events will help control order of run, but I found that not to be true. I do my database search in one custom event and the update in another, yet the first thing that happens in that workflow is the database update, which renders the first custom event - the database query, irrelevant.

Don’t run custom events sequentially, They do not return values. (Though Bubble promised that they will in the near future :smiley:)

Run your custom events daisy-chain like

What do you mean “return values?” I didn’t know events return values, if I want to control the flow I have them update custom states.

What do you mean run them “daisy chain”?

Event 1

Event 1 Action 1
Event 1 Action 2 - with result of action 1
Trigger Custom Event 1
Custom Event 1 Action 1
Custom Event 1 Action 2 with result of Custom Event 1 Action 1
Trigger Custom Event 2
Custom Event 2 Action 1
Trigger Custom Event 3
Custom Event 3 Action 1

This is exactly what I’m doing.
But again, two problems:

  1. I can’t use the result of action 1 because it is a do search - search of the database , which doesn’t render itself to be used directly in proceeding steps.

  2. Bubble doesn’t care about my daisy chain. It seems to scan all the actions in the custom events down the chain, and if there’s an update to the database it runs that first. And it doesn’t even show it to you in the debugger so I can’t even trace what is going on.

Instead of “trigger custom event”, try “schedule custom event”. Each one will be an independant workflow.

That’s even less control than what I had.

But I also found out that I have another issue that may have been in interaction with this issue - I was updating the search field through JavaScript in an html item, and this is probably not something that can be trusted.

This topic was automatically closed after 14 days. New replies are no longer allowed.