I am familiar with the workflow “Schedule API workflow on a list”. This works fine for when I have one list. But how about when I want to create things from two lists?
I have a list of products (e.g. phones) and a list of offers (these are inputs from the user). When clicking “Save” I want to join the two lists and save them in my database, so that entries will be:
Phone: Phone A; Price: $20
Phone: Phone B; Price: $25
Phone: Phone C; Price: $22
The same might work even for more attributes (e.g. location, date)? But for now I’m just worried about two lists.
How can I accomplish this?
@fab118 have you tried this:
… merged with …
This operation merges two lists of things. It returns a new list with entries from both lists. If an entry is in both, it will only appear once in the returned list.
Hi Sem, thanks for your answer.
To clarify my question: the two lists would be a list of Products and a list of Prices. One Product and one Price would always make a pair (see above example). Initially the price data exists only as an input in the repeating group (Products are of the type “Product”, and Prices are actually inputs by users). When a user adds prices to the products and hits a button “Save”, the Product-Price pairs get saved in a separate table (let’s just call it ProductPrice).
This is a tricky one. There are a few avenues you could explore:
- Create/modify the price item and attach it to the product on the fly when the user modifies the price input. This may not work for you app setup, however, and might cause extra unused data to accumulate if users cancel.
- Create an API workflow that takes two lists, creates an item from the first entry in those lists, then calls itself with the two lists minus the first items. This might not be the fastest due to how bubble scheduling works.
- Use @keith 's ListShifter KW plugin (and make sure to buy him a coffee if this works). Its an extremely useful plugin that you can use to loop over data on the frontend without making an API workflow call.
Hope this helps!
Need help with your bubble app? Reach out to us at protomakr.bubbleapps.io
@fab118 as austin3 said, you can update on the fly a database field. Use autobinding for this feature. In that case, bind the price input field to the respected database field of the product that has the price field. As soon as the user enters a price, the database will get updated. Of course this is causing calls to the database so performance wise this can be harmful when you have lots and lots of users entering prices at the same time.
Another option might be to use custom states in which you load the database values, enrich them with values in your custom state (using thins like :plus item or :minus item
If this does not help you any further, feel free to share your app and I will have a look
@fab118, for an example and discussion about building carts in various ways (including how you might use List Shifter in that context), see my video here and the thread it’s part of:
@fab118 Hello ! I get the same issue… would you mind sharing how you have done ? thanks