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

8 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.

5 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?

I have just solved a similar issue using the List Shifter plugin, if thatā€™s any help. It allows for lightweight (client-side?) iteration, which allowed me to view a database and simply iterate across a returned field to perform a per-user action.

You can use Keithā€™s List Shifter or Viniciusā€™ Simple Looper. Iā€™ve made a video on how to do looping using List Shifter, not all of itā€™s relevant for your example but the first bit may be.

1 Like