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?
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)
+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.
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:
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”.
Using regex, truncate the string to preserve everything up through the first “y” - i.e. lop off everything after the first “y”.
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.
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.
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.