Forum Academy Marketplace Showcase Pricing Features

[New Feature] New Event: Do when condition is true

@josh : This event fires as soon as its condition is true. If ‘Run this’ is set to ‘just once’, it will run once per page load, either immediately (if the condition is true on page load), or later when it becomes true. If ‘Run this’ is set to ‘every time’, then if the condition becomes false and then later becomes true again, it will run the workflow again.

More tools, more easy it become. Thanks.

New possibilities!

@josh Thank you.

Here some exemples I’m adding :

  • hide/show a spinner popup “page is loading” according to the loading of a particular repeating group
  • have a 2nd shot trigger after page has finished loading for displaying data things for instance if some groups are empty, or to make a scroll down to a RG entry according to a url’s parameter
  • when running a workflow in the API (like a background process), trigger something when the result is available, ie the process has finished (can be usefull when waiting for response on a webhook for instance)
7 Likes

@vlad – great point! I’ve added a safety precaution to prevent that from happening: we don’t track changes to the condition while the workflow is running, so if it toggles on and off while the workflow is executing, only the final state will be counted.

2 Likes

Hi @josh - I am having problems using this event. I’ve reported the problem in another problem I am having (save entries from a repeating group to the database) - see Repeating Group problem

In a nutshell:
I want to read and then save the entries from a repeating group X-number of times. Where X = the total number of entries that are listed in the repeating group.

To do this:

  1. I set a counter Y that increases as each entry is saved.

  2. Then I check if the Y <= X using the “Do when condition is true” event

  3. Save the entry Y in a table

But for some reason I can’t get the “Do when condition is true” to run more than once. As soon as it finds the condition to be true the first time it stops and ignores the fact that the counter has increased and therefore the condition is no-longer true…

Could this be because you turned on the safety precaution you mention above.
If so, can you recommend a different way to approach this?
My only other option is to hard code the process to repeat a number of times but I don’t want to do that as the number X changes each time I run the app. :worried:

I very much appreciate your help!

Cheers,
Toby

Yeah, that’s because of the safety precaution.

Right now it’s deliberately hard in Bubble to build loops. The reason is that we’re sharing infrastructure between our users apps, and we don’t want a user running a workflow that saves a million things and impacts the performance of all the other apps.

We know this is a big limitation, and we’re working on two things to fix it:

-Dedicated hosting, so that performance-intensive apps can have their own database and do whatever they want to it without impacting other users

-A database system that’s more scalable, so that you can update a million things at once without causing an impact on the overall system performance.

These are both high priority goals for us right now and we’re hoping to have them ready to go in the next couple months. Once we have them in place, we’ll probably enable things like running a custom workflow on each item in a list, which would make it easy to do what you’re trying to do. Sorry for the inconvenience here – I know this is a painful limitation.

6 Likes

Hi Josh,
Thanks for the quick reply and for clarifying the case. At least I now know I am not going bonkers.

You say “deliberately hard” - does that mean there is a way to build loops? In my case I want to update between 3 and 30 records - so far less than the back breaking million. Can you think of a way to do that (perhaps set a limiter to run no more than 30 times)?

If not then I guess my only two options are to write the results to an external DB and then connect to that via bubble or to wait until I can do it inside of bubble.

Unfortunately I am a complete newbie in writing to “real” tables (MySQL etc) so if there is anyone out there who has some experience in that then I would love to see what and how you did that. My queries are pretty simple but even so I don’t really know where to start.

Anyway, thanks as always for the great support and for creating a cool tool!

Cheers,
Toby

1 Like

So happy I found these posts as I have been going between thinking I am very stupid, and then concluding that I must be a genius data scientist for realizing the necessity of loops when Bubble hasn’t. It’ll be a long wait.

As I mentioned on another thread, you can “loop” in Bubble by breaking out externally.

I happened to use Zapier at the time as it was easy to trigger bubble workflows from it .

But now that bubble can call an API , I wonder if you can pingpong back and forth between workflows that way.

1 Like

If you have a small number of items you want to loop over, one thing you can do is create a custom workflow to do the processing, then create a workflow with, say, 10 “trigger a custom event” actions. Call the first one on the 1st item on the list, the second one on the 2nd item, the 3rd one on the third item, etc. That’s how I would recommend handling this.

Nigel’s suggestion of doing it externally using Zapier or Blockspring is a good idea too, although I’d discourage trying to set up a pingpong effect: if you build something circular that starts generating a ton of requests to Bubble, it might trip the protections we have in place to protect our infrastructure.

3 Likes

Yes, do be careful…

But Hackers gonna Hack :slight_smile:

3 Likes

Thanks Josh. That’s what I ended up doing.
I set a state called “row_counter” and then and run a Custom Process that goes through each column in each repeating group. For each value in the RG I set the index’s value to that of “row_counter” and then store that index’s value in DB field.
I repeat that 10 times, each time incrementing the “row_counter+1”.

It’s a bit clunky but it works for that small number of rows.

I am going to see if I can do this via MySQL as suggested by @NigelG and @isy in a different post as I am hitting other limitations now (e.g. finding unique values).

1 Like

I can get my app to send emails to a user at a set time every day with this?

Looking forward to this feature too, I will crawl back my ambitions a bit. Basically wanted to run a workflow every 300 seconds automatically in the background, collecting information from an API.

Hey @csfalcao did you ever work out a way to do this? I am trying to figure out how to do something similar, triggering SMS rather than email. Any help appreciated!

Nope @david4. I 'll have to get help for this, or wait a new feature.

@steinhausler How would (or did) you increment the “row_counter” custom state? I’m trying to do that and can’t figure out how to set state to say +1 ???

@NicolasDap, Have you, or has anyone accomplished this? I am waiting on a stubborn api.

Accomplished a LOOP using Do This Every 0.1 seconds. Set a State to 0 then increment it by 1. And do when condition is <21. I also added a “flag” so it does not run when page is first loaded. So the condition is (<21 and flag = yes). Runs perfectly and able to run 20 workflows when I set counter to 0 and flag to yes. Of course 21 could be dynamic. Make sure your conditions are met and don’t go on for ever.

1 Like