Filtering and matching between two lists

Hi, need help on filtering and matching between two lists.

I have 4 type of things (data table)

Data Table 1. Product, with below fields;

  • Product Name (text)
  • Stock Balance (number)

Data Table 2. Customer, with below field;

  • Customer Name (text)

Data Table 3. Booking, with below fields;

  • Product ( list of Products)
  • Quantity (list of numbers)
  • Customer (Customer)

When a customer made a booking, with multiple products and multiple quantities, I create an entry in Booking (create a new thing) with a Customer, add list of Products and add list of quantities.

After that, in the same workflow, I want to make changes to multiple Product data table because I need to deduct the quantities of products that customer booked from Stock Balance field in Product data table.

I can’t seem to find a way to match back that lists of Product with the exact quantities for each product to be able to do minus math operation.

Can anyone help me out?

In the booking data table the product list and the quantity list…are they supposed to be matched to eachother?

Is the intention that product list item 25 is corresponding to a quantity list item number 25?

If so, that may be the issue…might consider adding a data table to make things easier…call it what ever you will, but capture the product item and quantity together in that data table…then in the booking you can have a list of that data type.

Then I believe you’d be able to do the math operation you need.

Thank you for your reply. Yes I need to know Customer A booked 3 quantities of Product A, 2 quantities of Product B, so that I can deduct the quantities booked from Stock Balance field in Product data table.

Creating another data table? Why I haven’t thought about that. Thank you. Will give it a try.

A lot of my issues were because I didn’t set up my database to make it easier to do it. I have a lot of data tables that don’t really seem necessary until needed for a particular function. I also use relational database structure.

If you are not familiar with I would research database design. There are sites that show the database design for different types of databases, like e-commerce etc.

Very helpful to first have a clear plan of what the app will do, what data is needed for it and how that data needs to be structured to make the things the app will do easier to implement.

I’ve started to spend time putting together the database on paper based on what I want to do, but I use examples from the web a lot to help me conceptualize what is needed.

I have a little bit knowledge on the database design. I have read and studied, know some relations, one to many, many to many and stuff.

But @boston85719, I having trouble to create multiple new entry in the database (newly setup, named Product+Quantity Ordered). The selected products by customer is in a repeating group (using custom state, :plus item), so when a customer select multiple products, the repeating group will display all of the selected products.

How do I create multiple new things in the database?

Most people use API workflows or recurring events

Looking into the API workflow as well. This something that i havent master

Hi @boston85719, I have managed to find a solution for this problem that I have. Basically what you are suggesting is right, using API Workflows (I have created and tested it successfully).

But I also have found another solution without using API Workflow. Please check here

Basically the problem I was facing is to deduct the stock count in my product inventory from the customer cart, once the customer confirmed purchase.

Thank you for taking time to reply and give suggestion to me.

1 Like

I’m glad you were able to find a solution.

One thing to keep in mind when faced with issues on bubble is that there are usually multiple ways to accomplish the same thing. With that in mind there will obviously be drawbacks and advantages that come with each.

The disadvantages of the method you linked is that it will happen while the user is on the page and will cause a delay; think the blue progress bar.

The advantages to api workflows is that they happen in the background I believe and seem to enable the changes to data to take place while the user is still on the app without needing to wait for the data changes to be complete ( think no blue progress bar ).

Keep in mind too what you have probably come to find with api workflows is that they are essentially the same thing as a normal workflow, but have the ability to be scheduled, and thus not affect the user experience.

My advice is to use what works best for you, but keeping in mind the users experience, any chance to speed things up would be appreciated by the end user.

True, now I realised and feel that using API Workflows is better in term of user experience, a little bit faster and lesser loading time.