Accessing data inside a repeating group (list of inputs)

I am having trouble figuring out how to make data inside a RG (list of inputs) available for calculations.

The user will be presented with a table (projections over 30 years) where a list of inputs has an initial value of zero. The user can type values for different years in which they may want to make discretionary pre-payments (e.g. right column)

I was hoping that by using a using custom state, I can access the list of inputs. But I can’t seem to set the value for the state as the ‘list of numbers’.

I have tried setting the state on the RG or the input element. For the value field, the input list isn’t available. The RG (in which the input resides) is but that doesn’t contain the data entered into the input field.

I am using JS for all the calculations. I tried experimenting with the plugins (List Shifter, Orchestra and RepeatingGroup Tools) but couldn’t find a good way to run the calculations. The calcs are similar to a loan ammortization schedule and I need to display the projections for each year whereby the user can experiment with payments and interest rates (for individual years).

So I need to access the list of inputs and then make this list available to the JS function to loop through for the calcs.

Any ideas, how I could do this? Thanks heaps.

1 Like

How are you using JS? Are you trying to pass the values to a plugin? You could, each time the input’s value is changed, run a workflow on that trigger. Then you have access to the value of the input and the cell’s index so you can know what value goes with which year’s amount.

1 Like

If you want to calculate each cell separately, you can use a recursive workflow. Which loop over each cell and do calculations on it.

like there are 5 cells in your RG. you need an index value and a count value.

index can be => 1
count can be => yourlist:count This give you totally cell number.

you need to make a recursive workflow which do calculation on each cell at a time, and in side it you need to call it again and this time give is a index+1 to loop over next cell in repeating group

make sure you give it a termination condition so it wont loop over infinity.

like when index > count : terminate

I am using the toolbox plugin. I don’t need to save any data to the database as its an interactive calculator to show illustrations. So I figured that client side JS might be the quickest way (until I become more familiar with bubble and see if there is a better way).

Should I use a plugin like List Shifter to access the value of the input and the index? It doesn’t look like I can access RG data directly with the toolbox plugin…?

The way have structured the calculator, I am not sure if I can do that. I am not storing each row in the database - only the initial inputs. Then its JS formulas in a loop (toolbox plugin) . So I am not sure if the values of say year[i] can be made available to backend recursive workflow?

Its okey if your not saving data in database, but you are showing it i repeating group.

Which mean data is there in repeating group. You need to find each cell and do calculations on it right.

You can do it with recursive workflow as i said.

1 Like

I have done something similar to this without needing JS or any plugins.

How I did it was, adding a input element to the RG and had a workflow of “when input’s value is changed”, run the said calculations. Would be happy to explain further if this solves your problem

1 Like

@williamtisdale thanks for the tip. I am still struggling to extract the input’s value and index in a manner in which I can use it. I have been trying different approaches but can’t make it work.

Would appreciate if you guide me in the right direction. I have tried to use List Shifter to iterate over the list etc as well…

I can access the an input’s changed value and index but I haven’t been able to create a new list (or update the existing one with the new inputs) which has the updated inputs at the same index position as the input, while unchanged value stays as zeroes. Not sure what I am missing…

@ntabs That would be really helpful, if you could show me how you did it.

I have gone down the plugin route and haven’t had much success!

It’s pretty simple.

Like I said, I just added an input element in the RG and had a workflow “when input’s value is changed”, run the said calculation to the current cell’s thing.

In my case, this was product’s price and stocks - pretty simple calculations.

If you’re wondering how do you reference the calculations to a thing, you can just use current cell’s thing and start your calculation.

Please do note that this will also depend on your calculations if it’s very complex or not.

Thanks @ntabs

Yeah, I can’t use that approach as my calculations are more complex and need recursive calcs with multiple inputs. For now, I am doing them with custom JS but need to figure out if bubble’s recursive workflow will be faster (unlikely…)

@SK1, one of the easiest ways to loop client side is to use Vino Brito’s plugin Simple Looper:

  1. Install the plugin:

  1. Add the loop element to the page:

  1. Prepare a list to loop over:

  1. Add a custom state to the page (or one of the elements on the page) to keep track of the current loop iteration:

  1. Add an element + workflow to trigger the loop

image

  1. Define the steps to be performed during the loop:

  1. Update the state defined at step 4 to keep track of where you are in the list:

  1. You can use the state mentioned above to retrieve an element and its data from the list:

  1. And use the state mentioned above to determine to continue or stop the loop:

image

Note , you can use the Toolbox plugin to get data from Javascript back into Bubble, but you probably already figured that out.

hey, take a look at this article, maybe it will help, How To Use Group By In Bubble.io | In-depth Guide

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.