Bubble backend loop not working

Hi,

I’m having trouble using backend workflows to create a loop that runs through a list of files and adds them to the database.


Basic UI for the upload page

I have a multi-upload box where I upload several files to. From here I click the “Save Uploaded Files” button which calls a backend workflow called “Upload”. This workflow takes in 3 values:

  • UploadedFiles - List of files (The files in the multi-upload box)
  • Iteration - Number (A variable to loop through the list of files)
  • Count - Number (The number of files in the multi-upload box)


Calling the backend worflow


The backend workflow settings

The backend workflow then creates the shows using ‘item# iteration’


Creating a database entry using the backend workflow

Before then calling itself again and adding 1 to the “Iteration” variable. This should only occur when iteration is less than count.


Looping the workflow

However this is not quite outputting the correct result. For example, when uploading 2 files instead of just adding 2 files it duplicates the second.


With three uploaded files it goes even more nuts:


I’ve spent too long trying to figure this out and fear its something very simple that I’m missing. Any pointers would be greatly appreciated.

Thanks.

Shouldn’t you be calling “Upload” again in step 2? What’s the details of the “loop” workflow?

1 Like

Thank you my friend you’ve inadvertently helped me figure it out. Upon your query I went to look at the call action and it turns out I was re-calling it on a list of things which was playing havoc with how many times it was running. I’ve switch it to just schedule a regular API workflow and it works a charm.

1 Like

Hello,
I’d like to do more or less the same to send several email from a list of users.
I’m wondering what is your “Loop” action in your example. I don’t think there is such an action available in the regular Bubble list of action right ? Is this from an additional plugin ?
Thanks,
Laurent.