'Wait Until' Workflow Action

For some of the functionality I’m building in my app I need to have a certain action happen after an initial trigger, but only once another condition is also true.

For (a simplified) example - a button is clicked, and then when another thing has happened I need a custom event to run.

I can’t use the ‘do when condition is true’ trigger as I don’t want the event to run every time the condition is true, only when it’s true after an initial action has happened.

So, having a workflow action to ‘wait until condition is true’ would be extremely useful here.

In a similar way to using the ‘trigger custom event when data changes’ action, but being able to use an on-page state as the trigger rather than a database change.

So a workflow could look like this:

When button A is clicked - wait until condition is true (for example a custom state value equals something, or an element is visible) - then run next action.

Or

When Button A is clicked - Trigger Custom Event When Condition Is True

It could be useful to handle some more complex workflows.

5 Likes

+1 to this feature request.

As a workaround I’ve used in the past, you can have Button A set a page state (e.g. “pressed” = yes), and then have a “Do when condition is true: pressed is yes AND other condition is true)” And then have that workflow reset pressed to “no” or empty in addition to the other actions.

1 Like

Yeah, I thought of that workaround and that should work in the majority of cases…

But, specifically in my case, the additional condition refers to a custom state on an element inside a specific repeating group cell (each cell has it’s own state value) which is nested inside another RG, and there’s no way natively to access a custom state value of a specific RG cell from outside the RG.

I’m using the Orchestra plugin to do just that, but can’t figure out a way to combine that with the workaround you’ve suggested, as I can only access the internal RG states through the plugin - hence why a simple ‘wait until’ action would be perfect.

There probably is another workaround, possibly involving having a list state somewhere on the page, and setting it from within the RG cells (using the Orchestra plugin) then applying your workaround using a combination of ‘do when conditions are true’ conditions - I’ll keep working on it - but a ‘wait until’ action would be more elegant.

You’re right that it would. To solve your issue right now, I think the list on page state approach is probably the best. If your list type is a “simple” type (number, text, date, etc…) perhaps the best way is to have a list of “default” values that matches the RG, and then update the list using item #: current cell’s index. You’d have to get creative about how you do the default values though, since bubble doesn’t generally allow duplicate items in lists, even on page state.

1 Like

Can you state your exact use case here? My initial hunch when reading your post is that you’re thinking about building out workflows in the wrong way.

I’d love to take a shot at this.

Sure, it’s quite a specific (and seemingly simple) thing, but in Bubble it requires a few workarounds… (in any case I’ve got it working perfectly now so it’s no longer an issue)…

I have a repeating group, with another repeating group inside it and, on a particular action (specifically when a video is loaded into a Vimeo player, triggered by a Vimeo SDK event listener), I need to trigger a particular action inside a specific cell of a RG nested inside a specific cell of another Parent RG.

There’s no way to do that natively in Bubble, so I’m using the Orchestra plugin to be able to reference the specific cell inside the nested RG.

That’s simple enough and it all works fine when everything (including the second RGs) is visible on pageload.

But due to the fact the the nested RGs are hidden on pageload until the Vimeo SDK event listener triggers them to show and the way the Orchestra plugin works, the Orchestra element that needs to be ‘revealed’ before I can access the elements within the nested RG cell is not active when that event triggers (mainly due to the delay between the element being shown, and it actually being visible - made worse by the fact that I’m using animation to show the element).

(Without the issue of the animation delay, I could probably just use 2 custom events to ensure things happen in sequence, but as the animation happens after the element is visible, the workflow thinks the first event has completed (which it has) so tries to run the next event (when the Orchestra element hasn’t been ‘revealed’ yet as the element is still being animated), which is what’s causing the problem. I could just not bother with the animation - but it’s part of the UX/UI so I want to keep it).

If I run the second part of the workflow immediately, it’s too quick to catch Orchestra element inside the nested RG cell and the plugin returns an error.

The obvious workaround is to schedule a custom event on a time delay (500-1000ms), but that’s a bit hit-and-miss - too short and it doesn’t always work, and too long and it slows the action down unnecessarily - plus I don’t like like leaving things to chance, I’d rather know for sure that the first action is complete.

So, ideally, when the initial action is triggered (via the Vimeo SDK event listener) I could then wait until the Orchestra element inside the nested RG cell is ‘revealed’ and therefore available to the next step of the workflow (by setting a custom state once the plugin element is revealed) and then run the final action when that custom state value is true, that way always being 100% sure that the first action (the activation of the plugin element) has been complete, before attempting to run the next workflow action.

As it happens, I’ve managed to get it working perfectly using @austin3’s suggestion of setting 2 states (1 being a list of the nested RG’s cells who’s Orchestra plugin elements have been revealed) and running a ‘do when condition is true’ event when both are met (basically flipping the problem around and approaching it inside-out so to speak).

It seems to be running with 100% accuracy and is pretty fast - so I’m happy with the result - but a simple ‘wait until condition is true’ workflow action would have saved a few more complicated steps.

2 Likes

I think it’s a sensible idea. The absence of this workflow tired me out in many of my works.

1 Like

This is a must. Even more in API workflows where you can’t use states

1 Like

The topic is quite old but the idea remains the same
If would be interesting to schedule an API workflow after a precise event

3 Likes