How to iterate the list using Toolbox

Hi Everyone,

I am trying to iterate the existing list (get from the bubble database) using the toolbox. How can I do that?

What I have tried?


Problem I am facing- I am not able to figure out how can I pass the dynamic index into the “Do Search for” query.

@keith @lindsay_knowcode do you know anyway?

Thanks a lot.

Does the solution have to revolve around the Toolbox plugin? List Shifter does a great job with iterating and it does it fast.

Otherwise, you can use recursive workflows in the backend (you could also hack something together that does it on the client’s device, aka page workflow).

Could you describe the problem from the user’s perspective?

hey @rico.trevisan .

Thanks for chimping in.

Not necessary to use the Toolbox plugin, but I need the current item index to complete the logic.

Can’t use recursive workflows, since I need to call the API at the client-side based on the input and then again call the URL (that I will get from the API calling).

What exactly do I need -

On the user side-

There is a list of products, user can choose any number of products and add them to the cart(storing into Bubble database)

On the cart page, the user needs to click the checkout button (on clicking, I need to call Stripe Checkout API and pass the selected product’s price id )

In the Stripe API, I need to pass the array list like this-

list_item[0][price]="product_first_price_id"&list_item[1][price]="product_two_price_id" and so on.

To pass like this I am converting the cart item list to the text and send to Stripe as the text. (I checked using the hard code and its working, so making it dynamic)

Here is the video of what exactly I am trying to do- Loom | Free Screen & Video Recording Software

Set the search results into variables at the beginning, then use plain javascript to iterate over it. Mixing both is confusing for you and for bubble.

Remember to use the “Javascript to bubble” return element, don’t try to directly manipulate the bubble data here.

+1 for using ListShifter plugin as it combines the ListOfNumbers functionality with the ability to iterate over the generated numbers list. In workflows you have an event which gets called for each iteration and you reference the Current Iteration Index to get at it. Hope that helps.

I guess u can give it a try :wink:

How can I pass the data to the JavaScript array? It shows the error-


You can’t really initialize the search result in variable. Any other way?

try var array = ["search for cartItems: each items priceid join with ", " "];

1 Like

I tried with following-




but it never reaches to return statement.

You need to do like your first attempt:


But you need a “white” quote mark just before the final bracket.

Exactly like said.

Thanks @rpetribu but that is creating the text rather than an array. I think I need to further split text to array and then use it.

Let me try that.

This is what you need.


In the end of your function write something like:

console.log (arrayPrice)

Go to your browsers console and check the output.

Yes, I have checked it, using arrayPrice.length - it always returns the 1.

I have hundreds of lines just like this in my app. I work A LOT with arrays in Js. I am positive that this is creating an array.

Just made you an example with my app:

User database:






1 Like

This is indeed an annoying deficiency in Bubble - i.e. that there’s no simple way to get the index of an item in a list. (You can access the index of a cell in a repeating group but not of an item in a list.)

The good news is that there’s a very clever pure-Bubble work-around. There is no need for a RG, no need to iterate, no need for a plugin, and no need for Javascript. Kudos to @vovazk for coming up with it.

By way of overview… Given a list and a thing in that list, you can determine the index of that thing by:

  1. Formatting the list as text where each item is the boolean result of comparing the thing to that list item.
    This step gives you a string like “nnynnn”.

  2. Using regex, truncate the string to preserve everything up through the first “y” - i.e. lop off everything after the first “y”.

  3. Count the characters in the truncated string, and voila, you have your index.

Of course, it’s silly to have to jump through such a hoop to get something as simple as a list index, but until Bubble adds the capability, this is one way to go about it.


Got it, It was an error with “,”, need to pass extra "



Thanks for the solution but I am not able to understand. I am not able to figure out how “Formatted as the text for yes and no” action will come in Bubble.

@rpetribu thanks your solutions works.

1 Like

Yeah, I had to read the original post a couple times myself before it sank in. When I get a chance, I’ll put together a working example so that anyone can see it in action. Sounds like you’ve found another work-around in the interim.



Yes, the other solution worked pretty well.

Thanks for your time. @sudsy

Waiting for the working example.