Forum Academy Marketplace Showcase Pricing Features

[Solved] Stop an incremental (do when) workflow (Exceeded monthly workflow)

Hello…and help!

I have been on bubble for just 20 days and have exceeded my monthly workflow limit. The culprit, I suspect is an incremental countdown (Do every 1 sec), as it is creating a workflow every one second while the condition is true.

The condition comes from a “duration” field in a thing. When the page is loaded the duration is set depending on the thing chosen, and when the user clicks a button the countdown begins. When “duration” is <= 0 then another button appears for the user to be taken to the next page (if this happens then the workflow stops).

I can easily change the increment to minutes instead of seconds and that will save me 60 WF calls per minute, but my fear is the user that may leave their browser open and never click that button to move on - all the while the Do when is still going.

Is there a way to stop the workflow after the timer reaches 0, so that no matter what the user does at least the workflows stop when the duration = 0.

Thank you.

@NigelG

I believe Nigel made a post about how to do this using Custom States, but I can’t find it. In short, there’s a way to do this that does not use workflow runs. I’d hunt through the forums if I were you, I know it’s in there somewhere! Sorry I’m not more help :confused:

2 Likes

@potentialthings - thanks for the info, I’ll look into the custom states…

For now I came up with a work around:

  1. I changed count down to minutes from seconds so there is not as many workflow calls
  2. When the duration counts down to 0, a button appears for the user to take them to another page (which would stop the timer workflow - I keep the countdown going for a couple minutes, if they do not click that button then a popup pops up to ask them if they’re still there.
  3. If the user does not click the button in popup after certain amt of time then the system logs them out.

How did you see your workflow usage?

The custom state is a browser local storage place to store your timer value, instead of in the database. You can choose to add the custom state to the page, or to an element such as a text.

On the workflow editor, for the interval timer event, add an action, choose Element Actions > Set State. Then pick either the page, or one of the elements to store the state, then on the Custom State, choose create a new state and give it a name.

This state can then be referred to in any dynamic data by choosing the element, then the state name. You can do this for setting the value to the existing value -1 in the value field of the action.

1 Like

@mishav - so essentially what you’re saying is that the custom state allows me to use a text element as a timer (and placeholder) and I can modify this instead of modifying a number field in my database every time the increment happens?

1 Like

Yes, the state is a hidden component of the element, which you can use how you like. You can make many of these of different names for different purposes :slight_smile:

1 Like

Will give that a try…Thank you @mishav and @potentialthings

@cschrade here is an example:
edit:


preview:

1 Like

@mishav How could we access this browser localstorage state from native js? I have been looking around the inspect part but no trace of this in any standardized localstorage.

Can create a HTML bubble element, in it’s definition have javascript which uses a value, and make that value be dynamic data using Bubble’s editor. This makes the HTML element reactive to the custom state, i.e. will rerun the javascript if the custom state changes.

Edit: I’ve updated the example app above, here is what the HTML definition looks like:

FYI I used the term storage loosely, the custom state is just stored in the DOM for the life of the element.

Perfect…that did the trick - I’ve weened the app off of too many workflow calls to the database! - thank you very much @mishav and @potentialthings

1 Like