How to make reusable workflows reliable?

I am a long-time but infrequent Bubbler. I am resurfacing a problem that may be among the most serious problems I encountered four years ago after building a lot of reusable workflows in a reusable element.

In many cases the workflow calculates or formats a number of values that are stored in custom states and available to the workflow that triggered it. Unfortunately, the results are unreliable at best because the reusable workflow is still working (in parallel) while the triggering workflow runs its next action which needs the result of the reusable workflow.

A simple example is this:

Step 2 sets a custom state in the reusable element to a number of minutes.
Step 3 triggers a workflow that converts minutes into text representing the minutes as hours and minutes (hh:mm).
Step 4 copies the resulting text from the reusable element’s custom state into the local custom state (wPlanDurationText)

Results are unreliable, which I think means their always wrong.

What seems to solve the problem in this workflow is adding a pause between triggering the reusable workflow and then using its result.

Ugly, potentially wasteful of time and potentially unreliable.

I set the pause for 100ms. Is that always enough? Would 10ms be long enough? Always? If I have ten such workflows, am I not adding a full second to the UX?

Other than the Bubble builders providing the ability to create true functions in Bubble, what is the right solution here? What can be done that is not wasteful because of excessive time spent in pauses and what can be done to ensure that enough time is in the pause to guarantee correct results?, I was about to reply when your post was withdrawn.

As I understand “Only when” conditions on action steps, they will only prevent the step from executing, not pause the workflow until the condition is met. The workflow will go on its merry way and simply not execute the step that depended on the reusable workflow.

Yeah… honestly all of it is quite confusing still… and I’ve been at this for years, like yourself. :confused: I spend a large portion of my time working on little details like these on my apps. I usually end up having to do it a different way that may be more inefficient just so I don’t pull my hair out lol…

Put your set state as the last step of your custom workflow and use ‘as a result of’ values which forces the workflow to happen after those steps.



Thanks for the suggestion.

I don’t quite follow.
Setting the needed custom state is the last step of the reusable workflow (after setting other intermediate states.)

I don’t find ‘as a result of’ being an option for a step’s “Only when” condition.

@laurence when you set the value of the state in your dynamic data you should see ‘as a result of’ options to set the value of the state of your reusable element.

You can access the states of a RE from anywhere you have it, so you don’t also need to set a ‘local’ state that matches the RE state.

Currently you are seeing it be ‘unreliable’ because of race conditions.

PS. if you are already setting the custom state of the RE then your step 4 is redundant :wink:

My solution for these race condition issues on RE’s is a very tiny internal plugin called ‘Relay’ which sits on the main page with a yes/no condition expression inside that links to a state on the RE called something like “changes_made” or “continue_running”. When that condition is met then an event triggers from the Relay element and a workflow kicks-off on the main page. It’s essentially a fudged callback.

So you would update the state to “yes” inside the RE when you know the work is done → That will set off the workflow back on your main page → as part of that workflow you will reset the RE state back to “no”

See example below.

Happy to make it available if it’s going to help.

@equibodyapp in this context I don’t understand what “dynamic data” refers to.

And you’re right that step 4 would be redundant if I didn’t want to save the RE’s state value for other uses than just in this workflow. Any place the value is used outside this “local” workflow should not need to know about the RE. It’s classic thinking from the days of structured programming. (kind of like classic functions that aren’t supported by Bubble.)

@exception-rambler It seems that this requires the local workflow to be divided: one up to the point of triggering the reusable workflow, and a separate one for handling the result of the reusable workflow. Seems like it would work, but would be a bit of a kludge that gets in the way of workflow readability.

Correct. That would be your trade-off
I use colours and naming to pair them up

1 Like

Well since we are using Bubble ‘classic thinking’ doesn’t really apply does it :wink:

You can either hard key a state value or you can use a dynamic value.

Screen Shot 2022-02-09 at 8.28.40 am

Once a state is set it’s available for any conditions/other workflows until you set the state again

Right. Thanks.

Another thought. Please check me if I’m off track.
If a plugin can essentially implement a callback, what’s stopping the Bubble makers from doing the same in a way that allows a workflow to remain intact?

So right! Frustrating for a classic, I mean old guy, like me. :roll_eyes:

Thanks again for your help.

I’m not sure.
But probably because it falls in the big chasm between powerful game-changing, user acquiring feature, and painful, groan worthy, user churning bug. The people that spot it are usually also the people able to work around it.

In Bubble’s defence, the world of sync, async, requests, promises and callbacks in traditional development is a minefield and functions end up disjointed.

There’s several places where it would be great to be able to do ‘return’ values: from client-side plugin actions, from Backend API workflows called via Bubble (as opposed to API connector) and reusable element workflows too.

1 Like

@exception-rambler @equibodyapp

Thanks to all of you for your insights in this thread,
but . . .

I’ve been using Bubble for nearly 4 1/2 years and wasted literally weeks of my life because Bubble never explained workflow order of execution. Apparently it wasn’t until May '21 that something was done by Bubble to explain how it works.

and KUDOS to @cowontherun for making it graphic:

In the nine months since this was published, why wasn’t it repeatedly shouted from the rooftops, in the forum and in the Bubble dev UI so that everyone would have access to this information? I only stumbled on it today because I was digging deeper into what is missing in my understanding of workflows that has caused me so much lost time and deep frustration for more than four years.

No doubt Bubble is doing much better at transparency since the early days, but there is still a lot wrong with their documentation and communication about foundational behaviors.


Thank you for sharing the Order of Operation post and its discussion. Such good info and I do agree that it should be more widely known!

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