Perform 'for loop' in Bubble

Hello Bubblers,
I’d like to…

Search for thing1’s field1 :uniqe items as list
For thing1’s field1 in list:
…do search for thing1’s field2
…create new thing2 having sum of thing1’s field2’s values

I understand Bubble enough to perform the function, just not haw to make it loop. This is a pretty easy lift in python but I don’t know the the bubble workflows well enough to make it happen. Maybe a back-end workflow? (which I only vaguely understand right now) Maybe a plugin could help? (though I’d prefer if I could do in in native bubble if possible)

Any help is as always, greatly appreciated!

BR,
Will

Yup. You got it! Backend workflows. You create an API endpoint on the backend. Then you run it on a list from the front end. It sends each thing to the back end till it completes the list. Make sure your backend is enabled in Settings > API

Hope that helps! :blush:

@j805 www.NoCodeMinute.com

For All Your No-Code Education Needs:

  • One-on-One Tutoring
  • eLearning Hub
  • Video Tutorials
  • No-Code Classes
1 Like

Hi J805,
Thanks for the nudge in the direction of the back-end workflow. Below is what I have so far. Still stuck on how to make the API iterate over the list of results.

API Endpoint:
image

API Event:

<---- I can only select one item from my PartNum field, not a list. How do I iterate over the list of ‘PartNums’ here?

Workflow Event:
image

ScoresTmp:
image

Desired entries to be created in ScoresConsol: (Not working)
image

Thanks!
Will

loops are a real pain in the a** with bubble because they only allow recursion not loops. Too many users with no compsci understanding would crash their apps with infinite loops. If recursion is memory efficient for you go for it, if not, try out the “List Shifter” plugin its great.

I don’t believe you need to do anything on a list. Try setting up the looping BEWF as follows:

  1. Create a new API endpoint called something like “CreateConsol”.
  2. It will have 3 keys: PartNum, countPartNums, thisPartNumCount
  3. Add an action that creates your ScoresConsol for the current PartNum.
  4. Add an action that calls CreateConsol only when thisPartNumCount <= countPartNums.
    PartNum would be “Search for ScoreTmp’sPartNum:item#thisPartNumCount”
    thisPartNumCount would be thisPartNumCount + 1
    countPartNums remains constant throughout the loops.

Then finally add a button or some kind of trigger event that calls CreateConsol initially and sends the 3 parameters.
PartNum would be “Search for ScoreTmp’sPartNum:firstItem”
thisPartNumCount would be 2 (as the first one gets created on the initial loop)
countPartNums would be “Search for ScoreTmp’sPartNum:count”

I have the exact same scenario except I am creating new “kits” for my new users, but the same logic applies:

Here’s the Looping BEWF:

Here’s the trigger event:

1 Like

@SerPounce,
Thanks for the very verbose write-up (with screen shots, even)! I’ll take a whack at this tonight and let you know how it goes!

BR,
Will

1 Like

Congratulations for your work

Hello, I found your plugin very good, but in my use case here, I need to fill in data from a list within another list, I iterate over a list of products, and within each product there is a list of complements, so at the end of product iteration action I call the complement iteration, but it only does the first element and moves on to the next product iteration … can you help me?