Issues with workflow/step sequencing

A million threads about this, but hoping someone can help advise what to do for my specific scenario.

I have functionality that allows users to set preferences, say 4x favourite foods. There are 4 slots, and for a specific business reason Slots 1 and 4 could be filled with slots 2 & 3 empty.

Upon hitting save, the following workflow runs:

Steps 2-5 are all iterations of the following (1 for each spot):

These all run completely fine.

After these run, I use a custom event to do some more things (I previously had these in the same workflow but was told if I put them in a custom event it will force them to happen sequentially).



My issue is the ‘Only when’ fires inconsistently for the ‘Search for Depth Charts: count < 1’, yet works completely fine if I use the debugger. In the custom event, Step 1 corresponds to Step 2 in the original workflow. Bubble seems to be making the evaluation for Step 1 in the Custom Event before Step 2 in the original workflow is fully complete.

Hard to debug because as I said, it works completely fine.

Can anyone help… Is there any way I can force things to happen one after the other in this scenario… -.-

the only way to be sure actions are run in sequence is by referencing a preciois action or by using custom events.
Actions inside a custom event follow the same order of actions rules, so they execute sequentially only if they reference previous steps.
If you don’t reference any previous step but you want to run the actions sequentially then ise custom events. You can also create a chain of custom events: one event execute one action (or more action that can execute at the same time regardless of the order), then at the end triggers the custom event with the next action, that at the end triggers the cusctom event with the next action, and so on.

3 Likes

My issue is the ‘Only when’ fires inconsistently for the ‘Search for Depth Charts: count < 1’,

I don’t know what your search is searching for…so I can’t give a specific answer… but relying on a search of something you’re either creating or modifying in the same workflow is never a good idea - so if that’s what you’re doing that’s probably the issue.

If you want/need to ensure that certain actions wait until previous actions have completed before they start you need to refer to the results of that previous event in some way (either in the action itself, or in a condition).

3 Likes

Hi. Familiar with exactly the experience you’re having - frustrating!

Are you doing all of this on the page or in the backend?

I’d highly recommend looking at recursive workflows (Bubble docs) for this type of thing. It’s a bit more hassle to get started but gives you a lot more reliable control.

It means (a) you can have one action that repeats for each of your 4 (or any number of) steps, and (b) you can set up actions that definitely only happen when it’s finished doing its loops.

Hope that helps.

James
AppEDGE

1 Like

I completely realise how difficult it is for anyone to provide advice with how vague i’ve been.
:sweat_smile:

My database has a Depth Chart Data Type. There are 4 records (Things) for each position in a sporting team. Each Thing represents the ranking of players for a position, 1st through 4th. So for a rugby team which has 15 positions, there would be 60 things (4x15) for each team. Each Depth Chart thing has a membership field, which links to a player.

Users can use this screen to update the Depth Chart for each position.

Each a slot is a Depth Chart, showing information from Depth Chart Membership field. I have updating Depth Charts working fine, users can reorder, add and remove players.

A player can be appear more than 1 time in a depth chart, across multiple positions e.g. they could be the first string blindside flanker (#6) and second string lock (#4 / #5).

My issue is updating the Memberships that exist on another data type called Group. There is a Group thing for each team, which has a memberships (List) field. When I add or remove memberships from the Depth Chart, I need to check the Memberships field on the Group to see if I need to also add or remove from that (i.e. if it’s the first time the membership has been added to the Depth Chat, I also need to add it to the Group - and if it’s the only instance of the Membership that is being removed from the Depth Chart then it also needs to be removed from the Groups Memberships.

The Groups Memberships is used in other areas of the app for searches, permissions etc.

The above workflows are my attempt to update the Groups membership.

I update the 4 Depth Charts, then for each Depth chart in the custom event do a check (the big Only when) for each Depth Chart to see if I need to remove the memberships on the Groups thing.

Note: the Confirm Changes button only processes reorders and removals. Adding is done through a seperate pop up, when the user clicks ‘+ Add Player’

Thanks, I’ll have a re-read through and have a crack

1 Like

@appedge I’ve got it working (unless some weird edge cases pop up)… thanks so much!

It does mean that there is a slight lag on the team’s roster being updated (1-3 seconds), but that’s okay I guess…

In case anyone else stumbles upon this, this is the backend workflow I created:

1 Like

Excellent work and thanks for the update! Really glad it’s up and running.

Good luck with your project.

James
AppEDGE

P.S. Grateful if you could mark my earlier reply as a solution if you think it set you on the right path…