We just released a “Do when condition is true” event. This event will run as soon as its condition becomes true… either immediately when you load the page if it is already true, or once it becomes true later. You can configure it to run once per page load, or each time the condition becomes false and then true again. For more information:
this is awesome!
@josh - purely hypothetically speaking of course, if the workflow is set up to run every time and within that workflow I make the condition false and then true again, will I create an infinite loop?
Always good to see new features. Anybody care to share a few examples of the practical applicability of this feature?
@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.
@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)
@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.
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:
I set a counter Y that increases as each entry is saved.
Then I check if the Y <= X using the “Do when condition is true” event
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.
I very much appreciate your help!
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.
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!
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.
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.
Yes, do be careful…
But Hackers gonna Hack
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).
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!