# Issue with Workflow Order – Custom Events Executing Out of Sequence

**URL:** <https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342>\
**Category:** Need help\
**Created:** [April 1, 2025, 1:40pm UTC](https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342 "2025-04-01T13:40:51Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcamorrag](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dcamorrag/32/245380_2.png) [@dcamorrag](https://forum.bubble.io/u/dcamorrag)\
**Post date:** [April 1, 2025, 1:40pm UTC](https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342/1 "2025-04-01T13:40:51Z")

</div>

Hello! I’m experiencing an issue where my workflows made with Custom Events are not executing in the expected sequence. I have a process for creating a session that involves two validation steps before the session is actually created. However, Bubble seems to **execute the “Create Session” step before completing the validation steps**.

**Expected Workflow:**

1. **Button Clicked** → Triggers **“Check for Duplicates”**.
2. **Custom Event: “Check for Duplicates”**

- If a duplicate is found (`count > 0`), show an error and **terminate workflow**.
- If no duplicate is found, trigger **“Check for Overlaps”**.

1. **Custom Event: “Check for Overlaps”**

- If an overlapping session exists (`count > 0`), show an error and **terminate workflow**.
- If no overlap is found, trigger **“Create Session”**.

1. **Custom Event: “Create Session”**

- Only executes if called from “Check for Overlaps”.
- Creates the session and shows a success message.

**The Problem:**

- Even when a duplicate or an overlapping session is found, **Bubble still creates the session**.
- I added **“Terminate this workflow”** in both validation events, but it doesn’t stop the execution.
- I tried using **Custom States** (`can_create_session = Yes/No`), but this didn’t help—when updating the state, Bubble **immediately creates the session before completing the validations**.
- I also tested **removing all unnecessary workflow steps** and only triggering events in sequence, but **it still misfires**.

### **🔹 What I Need Help With:**

- Ensuring that **Bubble does not execute the “Create Session” step unless all validations pass**.
- Understanding why **Terminate this workflow** is not stopping execution within Custom Events.
- Confirming if there is an internal Bubble behavior that might be causing workflows to run in parallel instead of sequentially.

I’ve tested multiple approaches, but none seem to solve the issue. I would appreciate some help!

I attach some screenshots of my Workflow.

 ![Step 1](https://us1.discourse-cdn.com/bubble/original/3X/0/e/0ede6b448413ba5668fe8770cc914ec4979bafc1.jpeg)  
 ![Step 2](https://us1.discourse-cdn.com/bubble/original/3X/d/5/d53811b6e08c09c8376e28608b789c043a0b5ee4.jpeg)  
 ![Step 3](https://us1.discourse-cdn.com/bubble/original/3X/8/8/883b72457568b242d3a1012afb03925194cb153e.jpeg)  
 ![Step 4](https://us1.discourse-cdn.com/bubble/original/3X/e/1/e174c34a596ab83498970cc6cfef3a9bf383b5ee.jpeg)

Thank you!

---

<div class="post-metadata">

**Author:** ![ademiguel](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/ademiguel/32/245027_2.png) [@ademiguel](https://forum.bubble.io/u/ademiguel)\
**Post date:** [April 1, 2025, 6:50pm UTC](https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342/2 "2025-04-01T18:50:40Z")

</div>

Conditions to execute the `Terminate this workflow` actions and those for invoking Custom Events (CEs) are mutually exclusive, so the fact that the process keeps invoking the next CE is not in contradiction with the `Terminate this workflow` actions not being executed.

The problem here seems to be that the invocation of CEs is apparently firing when it shouldn’t. So, we should have a look at the conditional allowing to invoke the CEs.

Can you confirm that the condition evaluates to something you don’t expect?

---

<div class="post-metadata">

**Author:** ![justin.j](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@justin.j](https://forum.bubble.io/u/justin.j)\
**Post date:** [April 1, 2025, 7:25pm UTC](https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342/3 "2025-04-01T19:25:38Z")

</div>

I’d recommend going through the debugger step-by-step and checking those conditions which are failing to trigger the `terminate` action

---

<div class="post-metadata">

**Author:** ![dcamorrag](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dcamorrag/32/245380_2.png) [@dcamorrag](https://forum.bubble.io/u/dcamorrag)\
**Post date:** [April 2, 2025, 2:49pm UTC](https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342/4 "2025-04-02T14:49:47Z")

</div>

I didn’t know about the “Terminate this Workflow” behaivour. Thank you.

The conditions are not the problem. They behave as expected if I delete de CE “Create Session NP”. The problem is that the session is created before anything else, and it makes everything to fail.

Debugging step by step everything follows the woorkflow as it should, but the problem is that as the session is created at first (for some reason I don’t know).

May it be a bug?

---

<div class="post-metadata">

**Author:** ![dcamorrag](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dcamorrag/32/245380_2.png) [@dcamorrag](https://forum.bubble.io/u/dcamorrag)\
**Post date:** [April 2, 2025, 2:50pm UTC](https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342/5 "2025-04-02T14:50:53Z")

</div>

The problem is that as the session is being created at the beggining (I don’t know why) it triggers the ‘wrong’ conditions.

---

<div class="post-metadata">

**Author:** ![justin.j](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@justin.j](https://forum.bubble.io/u/justin.j)\
**Post date:** [April 2, 2025, 3:16pm UTC](https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342/6 "2025-04-02T15:16:56Z")

</div>

Workflow actions on the front-end shouldn’t run asynchronously so I don’t think that’s the problem.

What are the search parameters on this action? It could be that this action is failing to set it to `yes`

`Search for Sessions:count is 0`  
 ![image](https://us1.discourse-cdn.com/bubble/original/3X/0/8/08fc6c3620fc4488aa6470b069c42a24f7e30332.png)

If I understand, you have the same condition here, it could be either your `Search for Sessions:count is 0` is not set up properly, or your `Group Widget Nueva sesion NP's Crear Sesion is yes` is actually `no`

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/3/3/33f6592b680c242a97448d56cda3faf4e3ea7734.png)

I did find a useful thread here

> [@Order of Operation](http://forum.bubble.io/t/order-of-operation/151699/2):
>
> Hey there, thanks for posting! If you’re interested in Order of Operations, you might check out this section of our Custom States tutorial: [How to Use Custom States | Bubble Tutorial - YouTube](https://www.youtube.com/watch?v=ydqXrIgTekE&t=185s) Then, here is some information about Bubble workflow logic: For efficiency purposes, workflows run in parallel across the server and the front end. Despite the names “Step 1”, “Step 2”, it is important to note that a given step does not necessarily wait for the previous one to complete before triggering …

> [@Order of Operation](https://forum.bubble.io/t/order-of-operation/151699/2):
>
> - Custom events run in sequence, not parallel. If Workflow 1 triggers a custom event that starts Workflow 2, Workflow 2 will complete before the remaining actions in Workflow 1 run.

It seems like there might be a race condition in your logic, but I wouldn’t know unless we dug deeper into the workflows and debugger / logs.

---

<div class="post-metadata">

**Author:** ![ademiguel](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/ademiguel/32/245027_2.png) [@ademiguel](https://forum.bubble.io/u/ademiguel)\
**Post date:** [April 2, 2025, 3:25pm UTC](https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342/7 "2025-04-02T15:25:02Z")

</div>

Weird thing. What should these `Verificar Duplicados` and `Verificar Solapadas` CEs conditions evaluate to when the bug happens? True or false?

- `Only when Search for Sesions:count > 0`
- `Only when Search for Sesions:count is 0`

---

<div class="post-metadata">

**Author:** ![dcamorrag](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dcamorrag/32/245380_2.png) [@dcamorrag](https://forum.bubble.io/u/dcamorrag)\
**Post date:** [April 2, 2025, 5:43pm UTC](https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342/8 "2025-04-02T17:43:17Z")

</div>

Hi! Thanks for taking your time and answer.

The ‘Set State’ is not changing nothing, actually. If I delete it, it will run the same way. I just put it in order to add another conditional, but it does not works.

The problem is when there is the action “Create a Session”. When I put it, it will be created before anything else.

I’ll try to post a video so you guys can see.

---

<div class="post-metadata">

**Author:** ![dcamorrag](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dcamorrag/32/245380_2.png) [@dcamorrag](https://forum.bubble.io/u/dcamorrag)\
**Post date:** [April 2, 2025, 5:56pm UTC](https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342/9 "2025-04-02T17:56:23Z")

</div>

`Only when Search for Sesions:count > 0` is the condition that detects duplicates. If there is another session that has the same information as the one that is being created, then shows an alert and should end the workflow (or in that case, should not pass to the next CE).

**Right now, when the bug happens it is evaluating:**  
`Only when Search for Sesions:count > 0` as True  
and  
`Only when Search for Sesions:count is 0` as False, but just from the CE`Verificar Duplicados`, because once evaluates it as False, the Workflow ends.

**In order to create the session:**  
The `Only when Search for Sesions:count > 0` condition from both CE should be False  
and  
The `Only when Search for Sesions:count is 0` condition from both CE should be True.

---

<div class="post-metadata">

**Author:** ![ademiguel](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/ademiguel/32/245027_2.png) [@ademiguel](https://forum.bubble.io/u/ademiguel)\
**Post date:** [April 2, 2025, 6:08pm UTC](https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342/10 "2025-04-02T18:08:29Z")

</div>

In order to verify we are dealing with a bug, try placing a couple Text elements on screen that show the results of both conditionals, **with exact same constraints for the `Search for` expressions**.

If they return this below, and the `Sesion` gets created, we are seeing a normal behaviour, no bug.

> [@dcamorrag](#):
>
> The `Only when Search for Sesions:count > 0` condition from both CE should be False  
> and  
> The `Only when Search for Sesions:count is 0` condition from both CE should be True.

If we see this, and the `Sesion` gets created, then it’s a bug.

> [@dcamorrag](#):
>
> `Only when Search for Sesions:count > 0` as True  
> and  
> `Only when Search for Sesions:count is 0` as False, but just from the CE`Verificar Duplicados`, because once evaluates it as False, the Workflow ends.

---

<div class="post-metadata">

**Author:** ![dcamorrag](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dcamorrag/32/245380_2.png) [@dcamorrag](https://forum.bubble.io/u/dcamorrag)\
**Post date:** [April 2, 2025, 6:10pm UTC](https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342/11 "2025-04-02T18:10:18Z")

</div>

[Video where you can see the Step by Step and the premature creation of the session.](https://drive.google.com/file/d/1CqKfNCb5SS3pCd-rCXRQO7BXaWAU5W1T/view?usp=sharing)

---

<div class="post-metadata">

**Author:** ![dcamorrag](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dcamorrag/32/245380_2.png) [@dcamorrag](https://forum.bubble.io/u/dcamorrag)\
**Post date:** [April 2, 2025, 6:17pm UTC](https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342/12 "2025-04-02T18:17:11Z")

</div>

Sorry, but I did not understand exactly how to do that.

In case it is useful, I did a video where you can see how the session is created before anything else. If not, could you explain me exactly what to do, please? Thanks!

[Video - Step by Step and the premature creation of the session.](https://drive.google.com/file/d/1CqKfNCb5SS3pCd-rCXRQO7BXaWAU5W1T/view?usp=sharing)

---

<div class="post-metadata">

**Author:** ![justin.j](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@justin.j](https://forum.bubble.io/u/justin.j)\
**Post date:** [April 2, 2025, 6:20pm UTC](https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342/13 "2025-04-02T18:20:13Z")

</div>

Definitely looks odd, I would go back through your server logs from `3:00-3:02` and see what action triggered to create the item in the DB, it could be firing from another action that’s not included in your custom event, otherwise it might be a bug.

---

<div class="post-metadata">

**Author:** ![ademiguel](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/ademiguel/32/245027_2.png) [@ademiguel](https://forum.bubble.io/u/ademiguel)\
**Post date:** [April 2, 2025, 6:26pm UTC](https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342/14 "2025-04-02T18:26:45Z")

</div>

This is a weird behaviour of the debugger, I’ve seen it before.

But I see no bug in your execution, the `Sesion` gets created because there is no duplicated `Sesion` in DB.

If you try executing it again an a second exact `Sesion` gets created, then it’s a bug.

---

<div class="post-metadata">

**Author:** ![dcamorrag](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dcamorrag/32/245380_2.png) [@dcamorrag](https://forum.bubble.io/u/dcamorrag)\
**Post date:** [April 2, 2025, 6:30pm UTC](https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342/15 "2025-04-02T18:30:11Z")

</div>

But that weird execution is triggering the alerts. Then when someone is creating a session, always will appear the alert “That session was not created because is a duplicate”.

How can I solve it?

---

<div class="post-metadata">

**Author:** ![ademiguel](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/ademiguel/32/245027_2.png) [@ademiguel](https://forum.bubble.io/u/ademiguel)\
**Post date:** [April 2, 2025, 6:31pm UTC](https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342/16 "2025-04-02T18:31:12Z")

</div>

Try executing it without the debugger, just as a normal user would do.

Let’s see if the bug is present then.

---

<div class="post-metadata">

**Author:** ![dcamorrag](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dcamorrag/32/245380_2.png) [@dcamorrag](https://forum.bubble.io/u/dcamorrag)\
**Post date:** [April 2, 2025, 7:00pm UTC](https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342/17 "2025-04-02T19:00:08Z")

</div>

I looked and I think there’s something weird. I am not used to look at the logs, but it starts with the “terminate this workflow” conditions:

 ![Log 1/3](https://us1.discourse-cdn.com/bubble/original/3X/d/1/d146c13f17707d33d7752cd69b511b31135c87dd.jpeg)  
 ![Log 2/3](https://us1.discourse-cdn.com/bubble/original/3X/f/2/f2a02b300de2d7c08d63ec7dcfd264b12b018748.jpeg)

 ![Log 3/3](https://us1.discourse-cdn.com/bubble/original/3X/0/d/0df3a858d822da0514f11100720d8ba0cc63a19d.jpeg)

---

<div class="post-metadata">

**Author:** ![dcamorrag](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dcamorrag/32/245380_2.png) [@dcamorrag](https://forum.bubble.io/u/dcamorrag)\
**Post date:** [April 2, 2025, 7:01pm UTC](https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342/18 "2025-04-02T19:01:32Z")

</div>

Same problem running normal.

---

<div class="post-metadata">

**Author:** ![ademiguel](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/ademiguel/32/245027_2.png) [@ademiguel](https://forum.bubble.io/u/ademiguel)\
**Post date:** [April 2, 2025, 8:53pm UTC](https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342/19 "2025-04-02T20:53:04Z")

</div>

Please record another video, **running without the debugger active** , showing the next steps:

1. Show DB table for `Sesion`
2. Click the button. It should run without alert being shown. `Sesion` should get created.
3. Show DB table for `Sesion` again. The newly created`Sesion` should be there.
4. Click the button again (I guess this will try to create a duplicated session). The alert should show now. No new `Sesion` should be created.
5. Show DB table for `Sesion` again. No new`Sesion` should be there.

If what’s described in previous steps don’t happen as expected, show logs

---

<div class="post-metadata">

**Author:** ![achen2222](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@achen2222](https://forum.bubble.io/u/achen2222)\
**Post date:** [April 2, 2025, 9:21pm UTC](https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342/20 "2025-04-02T21:21:51Z")

</div>

from a programming point of view instead of nesting your workflows like that, create your 3 workflows and have them each return a value (return a value step is hard to find so just type return when you are creating the step).

have the top level work flow call the first one (which will have a value) then the second one only if the first step condition was met. Then the third one only of the original conditions are met.

In general your custom event should take parameters and return values rather than pulling in information from all over the place. This keeps the workflow tidy and allows you to test it more easily.

[Next page](https://forum.bubble.io/t/issue-with-workflow-order-custom-events-executing-out-of-sequence/365342.md?page=2)
