Access custom state inside repeating group with button outside

Hello, Bubblers. This issue has been bugging me for some time now, and I have come across it several times. So maybe someone here can help for future reference.

I have a repeating group with a list of products where you can select the quantity of the product. I do this with a custom state that counts +1 when the button “plus” is clicked and -1 when the button “minus” is clicked.

So the repeating group could look like this:
Milk - 1 +
Sugar - 2 +
Garlic - 0 +

I could just make it create a new thing in the database and make a change when a user clicks the plus or minus, but that is waaaaaaay too slow if the user clicks fast, and the custom state is instant and I can’t have multiple of the same thing in a custom state.

Next, I want to create database entries for every entry in the repeating group where the count is not 0. I wish to do this with a button outside the repeating group with the product and the count of that product for every product. I can’t seem to do this, does anyone have a solution?

1 Like

api workflows

Hi Boston! Thank you for the reply. Yes i know of the API workflows and it is also what i am trying to use.

What i am having trouble with is taking the custom state of products and the custom state of quantitys and then saving those to the database as new cart entries, like:

List of Products: Milk, Cheese, Garlic
List of Quantity: 2, 3, 1

Carts In database: Product Quantity
Milk 2
Cheese 3
Garlic 1

So in your database you have a data type called “cart” with data fields for “product” which is related to a data type called “product” and a data field “quantity” which is a number?

If you follow the video tutorial you should be able to see how to set parameters. Your parameters would need to be dynamically set to the custom state for product, quantity and cart.

Your page would have a custom state of cart which relates to the data type of “cart” and should be set when a user selects their first product to be added to cart. Also, when they add the product to cart the custom state for products which should be a list has the product selected placed into the cart.

Your custom state for quantity should be a list of numbers and be correlated (ie: ordered) the same way the products list in the custom state products is.

My overall suggestion would be to follow the video tutorial and see exactly how Gaby had set up the page and any, if any custom states.

1 Like

I actually got this working, but the schedule a workflow on a list is just not suited for any use in regards to this case. As with just 5 entries it only has a 50% succesrate of actually adding the products to the cart, so product 1 and 2 will be added in the schedule a workflow on a list workflow, but not 3 and 4. Which is not ideal for the user, as the user might select 4 products but only see 2 in the cart added.

I read that this might be a capacity problem, but with so low amount of items on the list, it just seems odd to even have the ability, if it is so unreliable.

I ended up just doing everything in the workflow on the page with create a new thing and make changes to a thing, as i can’t hold multiple of the same item in a custom state and i can’t count the amout of products quantity because there can only be 1 entry of the same item, so if a user selects 2 apples and 2 eggs, the list of quantity will only have one, like this: [2] and not multiple like this: [2, 2].

I tried adding the quantity to the name as a text with find & replace like so: Quantity number|Apples and then save it to the custom state and then extracting the number with regrex after, but that did not work as now it is a text (can’t do any calculation).

Best regards.

Take a look at this plugin: [New Plugin] bdk RepeatingGroup tools

It gives you the ability to extract input values inside a repeating group cell from outside the RG, that way you can avoid making lots of database changes and use inputs instead.


Cheers,
Gaby

Coaching No Code Apps
Join our Facebook group for insider access to no-code development
Get professional development services
Enroll in expert-led courses and products

2 Likes

Hello,

I had a similar problem and I found a solution with this awesome plugin Active Cel. You can now give an action to each cell of your repeating group from a button outside the RG.

Have a look on the app.

4 Likes

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