Forum Academy Marketplace Showcase Pricing Features

Loop Function PLEASE / Loop Through Repeating Groups

Given now each user has theire own allocated server capacity, can Bubble add Loop function?

I personally find it very-very frustrating not to be able to loop things.

PLEASE ALLOW AT LEAST LIMITED LOOP, e.g. 500 rounds.

Thank you very much.

Alex

5 Likes

Hi Alex,

It’s not obvious, but you can implement loops in Bubble.

image

Change 5 seconds to 0.001 seconds, or 0.0001 whatever.

image

Set up a condition on this workflow so that the loop is only running when condition ‘y’ is true. You can then start and stop this loop by changing the condition y on and off based on incrementation or whatever.

4 Likes

I need that also in the API Workflow (when no browser is open).

1 Like

Have you tried ‘Schedule API Workflow on a list’? You would need to get the items you want to loop through in a list and create an API workflow to perform the actions you need on each of them.

1 Like

Thank you very much, interesting solution.

The problem here is that even 0.000001 is slow.

@emmanuel is there a chance for quicker “looping”?

PS Loops would allow to go through a repeating group and change records from corresponding inputs (currently we have to allow auto-binding, i.e. call the server every time input is changed).

1 Like

What exactly are you planning on looping that quickly that it can’t be done using a scheduled workflow?

For example, I want to schedule a sequence of events in calendar, where date of an event is dependent on a previous event…

Example 2: I could loop through repeating groups and update them.

1 Like

Do you know how many events you want to schedule in advance ?

That is the thing - I know between what dates I need to schedule my events and depending on the selected frequency, events are created (there is logic inbetween some of the events).

At the moment, I use “templatee” events (created in advance), which get copied and then amended according to set paraments. This takes ages: to schedule 10 sequences (50 events) takes 3-4 minutes. I could do that quicker in excel.

1 Like

Can you use a set of date things, and update the relevant ones. That might be quicker ?

I do in fact use date* “things”, still, etakes time and quite a complicated workflow to implement the sequence :frowning:

Also, if one event is changed by the user, the whole process (of using a complicated workflow) has to be done again.

If there was a loop function, I could just fly through records (things) and create/update them.

The other thing is updating repeating groups from inputs, any suggestion how to do that without allowing auto binding (in other words create duplicates of all fields)?

Thank you.

1 Like

Hi again Alex,

The slowness comes from the operations you are carrying out within the loop, not the delay between iterations of the loop.

When the delay is set at 0.000001, for instance, you would need to execute the loop 1 million times before the cumulative delay between iterations of the loop equalled 1 second.

The delay has a very very minute effect on the speed at which you accomplish things through the loop.

If you are finding the loop to be slow, it is because operations being executed within that loop are slow. Bubble’s operations are just slow (creating things/changing things/ adding/ subtracting). That is especially true when using the database.

You can make loops run faster if you use ‘states’ as much as possible, rather than reading or writing values to the database.

A ‘faster loop’ will not help you. You need faster operations within the loop.

4 Likes

Robert, thank you for the explication.

Let me try to use your solution again (I did try before responding to you first time: I looped the creation of 100 records where only one field for modified on the way, this took about 5 minutes before I could see 100 records createde).

I shall try to compare looping with what I have at the moment and report back.

One more question, do you reckon having a script “do every xx seconds” on all the time somehow affect performance? Even if the loop isn’t actually looping?

It will always be looping if it is on.

You set a condition on the ‘do every x seconds’ to turn it on and off.

While the condition is ‘off’, and the loop is not running, the loop itself is not affecting performance.

(though the condition itself which turns the loop ‘on’ and ‘off’ will affect performance in a very very very minute way, and I won’t explain that because it will probably be confusing as it involves discussing Bubble’s underlying code)

1 Like

This is how I would suggest to implement this. Simple and powerfull…

A Workflow element holding the following entries

  1. Do while example: myElement State myValue is < 10
  2. to go step: example 3

So you could have a workflow for example:
Step 3: add 1 to myElement State myValue (myValue = 1)
Step 4: do search and replace some string
Step 5: Do while myElement State myValue is < 10 go to step 3

Step 3: add 1 to myElement State myValue (myValue = 2)
Step 4: do search and replace some string
Step 5: Do while myElement State myValue is < 3 go to step 3

Step 3: add 1 to myElement State myValue (myValue = 3)
Step 4: do search and replace some string
Step 5: Do while myElement State myValue is < 3 go to step 3 (condition = false)
Step 6: Continue here…

btw: I saw no-code authoring in the early 90s that did this… but coders seem ignore these, likely made accessible to others…

need this now… lol

wait a minute… you can do this with a DO WHEN always

then incrementing a state value until the condition is met… just make sure don’t go into an infinite loop

I am going to try it will get back…

Hi mente12,

We’re you able to do this?

Hey @luminrabbit :wave:

You can do loops easily with backend workflows nowadays.

Hope that helps! :blush:

@j805 www.NoCodeMinute.com

For All Your No-Code Education Needs: