Trigger Do Every x Seconds when Condition is Met?

Hi all,

I have a workflow that sets a state every x seconds, but it’s always running to check the condition is met.

I want to set the condition separately, so the “Do every x seconds” doesn’t run at all unless the condition is met. My current approach feels inefficient and makes debugging a pain unless you disable the workflow.

I can’t see a way to acheive that in the normal workflows or using custom events, can anyone think of a way to make it work?

Can you share the screenshots of your current approach?

@QIRO is your condition expression placed on the event or placed on the set state action inside the event?

You can use a timer/countdown plugin and a conditional event.

For example, when the page loads, set a stopwatch to run. And then create a workflow event with the following condition:

When… YOUR CONDITION and Stopwatch's value <modulo> 5 is 1
Run Every time

This will trigger your workflow every 5 seconds, without impacting your debugger if the first condition is not met :pray:

1 Like

I actually solved this by making a self-referencing workflow, with a delay of 1 second, that is only triggered if a specific element is visible.

That seems to have done the trick… :sweat_smile:

I think self-referencing workflows are not reliable and will usually stop at some point

As long as the page stays in an active browser and there is a clientside workflow running regularly then there should be no issues.

I use a do every X seconds event that updates a state for a queue number system that prevents the Bubble app page from “sleeping”.

Indeed I think Do every X workflows are reliable but I’m pretty sure self-referencing workflows have some sort of timeout/maximum on front-end.

You can reproduce by setting a button to Schedule a custom event in 30 seconds and clicking 50 times on this button, you will rarely get 50 workflows run

1 Like