Empty custom event respects workflow order?

So, something I have thought about but didn’t find anything on the forum. My understanding is that workflow order respects the custom events, so that if I have 2 workflows and afterwards a custom event with workflows, then those custom event workflows will wait for the 2 initial workflows to complete. What if instead of adding the extra workflows in a custom event (that require 1 and 2 complete), I add an empty custom event between the workflow 2 and the rest? would that work?

I can’t say for certain when each event gets triggered. However, it seems logical to me that they would run concurrently. In the original workflow, it only needs to trigger the other workflows. There won’t be any information returning to the original workflow. Perhaps it would be better to call the other custom event from within the first custom event? So, when custom event 1 finishes, you can trigger custom event 2 from its workflow? Or am I misunderstanding you?

As far as I understand it, putting a custom event in the middle of a workflow doesn’t change the order in which the actions are run…

With the exception of Scheduling an API Workflow (which always happens immediately), Workflow actions are triggered in the order they are defined in the workflow tab… it’s just that (for the most part at least) they run asynchronously (meaning they don’t wait for the previously action to completely before triggering the next) so, although they run in the order they are defined, they don’t necessarily complete in that order.

Custom events on the other hand, run synchronously… meaning that the when a custom event is used in a workflow, the subsequent actions in that workflow will not be triggered until the actions in the Custom Event have completed (that applies to vanilla Bubble actions anyway… it may or may not apply to custom code and plugin actions, depending on how they’re coded).

So putting an empty Custom Event in the middle of a workflow won’t have any affect on the order (or timing) of actions, as far as I can tell, as there are no actions to complete in the custom event.

So if you need to enforce the running order and/or timing of actions, either refer to the results of previous steps (where applicable), or break the actions up into Custom Events.

2 Likes

Let me try to ellaborate and add an image. My understanding in general is that if there are actions within a custom event, if this custom event is placed after some actions in the original workflow, all those previous actions will complete before start triggering the custom event actions, so in other words every action before the custom event have to run completely, and only after they finish, the custom event actions run, and when they are complete, it goes back to the original workflow and complete the remaining actions, and so on.

Given this, my idea is that Bubble might have “trigger a custom event” action as a placeholder, so that it knows that it has to run everything before that event, so in that case, if I have a “trigger a custom event”, even if it’s blank, it will still work as a placeholder, complete everything before it, go to the custom event, see that there’s nothing there, and then go back completing the remaining events. Like this:


Would that make sense?

@adamhholmes thanks for your inputs, is there any way you can think of for proving this is incorrect? My understanding is that you’re basically saying that Bubble understands the custom event as a placeholder only if it has workflows inside. First of all, you agree that if that custom event had events inside then the expected behaviour is what I’m sharing? or am I getting something wrong from Bubble there? and second, then if the custom event doesn’t have actions, would that still work as a placeholder? would be great to test it, cause a “workaround” could be just adding an action that does nothing jsut to make sure that the custom event runs.

Now, why am I pushing to understand this? casue this would solve ordering events in bubble if it works. You wouldn’t have to run actions within other custom events but rather just adding this empty custom event (or not emply but with something not actually changing anything) between the events that you want to separate triggering order. It would add a lot more order to my workflows tabs as it doesn’t have to jump to different workflows but rather having basically all at one.
Thanks for your perspectives!

I think its the opposite. Any wf steps AFTER the CE will only run after the CE completes

So in your case, without reading it too carefully it seems dumping all the WFs that are before the CE into their own CE will ensure they are all run before the second CE

1 Like

Your understanding here is incorrect…

It’s pretty simple to test this (and I just have, to confirm)…

It’s got nothing to do with placeholders, nor Bubble understanding, or not understanding anything…

As I said previously, workflow actions trigger in sequence. They just tend to run asynchronously (meaning they don’t wait for previous actions to complete before triggering the next)…

Adding a random empty Custom event won’t do anything to change that (again, it’s simple to test this kind of thing).

But, custom events should themselves run synchronously - meaning when a workflow gets to a custom event, the custom event (and all the actions within it) will be triggered before the next step in the main workflow is triggered.

That said, based on my test just now, I’m not convinced that the actions themselves within a custom event are synchronous…

It doesn’t appear to wait for them all to complete before resuming the main workflow - it just waits for them all to be triggered.

So the only way to reliable force synchronous actions is by referring to the previous step in the workflow (and you can only do that for server actions).

Interestingly, there seems to be some difference between different types of actions as to whether they are synchronous or not (e.g. Make changes to a Thing definitely seems to be asynchronous, whereas Make Changes to a List of Things is definitely synchronous.).

Just to give my 2 cents here…

1 Like