Hi
i searched the forum up and down, i am quite surprised i did not find anything like this, maybe i am the only one who could not figure it out
I have a few items of Data Type A i need to copy to Data Type B. Basically moving a certain seach criteria (e.g. Current User) to a different data type where most of the fields is the same, except the data type is different.
I created a simpler demo version if you could see what i mean. You will notice i treat all items separately (what i mean is if i add a ‘tv’ and later another ‘tv’ it lists them separately instead of adding them up in quantity. The reason is my app is a bit more complicated than the demo). You will also notice i created a field quantity, but did not use them, i just ran out of time before the current day job .
I manged to move one by one (there is ‘move to shopping cart’ and ‘move to wishlist’ icon in both shopping cart and wishlist popups, but the button in RED is the one i have no idea how to program.
I tried ‘Copy a list’ but that literally just duplicated whatever was in the current list in the same place (same data type), i was not able to see if it can be duplicated in a different Date Type as that would be a bull’s eye solution!!!
I am not sure how to run a ‘while’ or an ‘if’ loop since all is made so easy to use with Bubble!!! (this is not intended sarcastically, i absolutely love this product, take the programming out of building workable apps and reduces the time to build exponentially).
Any advice would be appreciated, just a nudge in the correct direction please.
So what you need is the “Schedule API Workflow on a List” function.
When the red button is clicked, you do this …
Which creates a Wishlist item for each item in the Shopping Cart.
For this I needed to create an API workflow, so went into the Settings/API menu and switched it on. There is now a new section in the “page” selector for API workflows.
wow, amazing, thank you very much!!!
Was able to duplicate it to move items from the wishlist to the shopping cart and add a ‘delete’ API in a similar way to empty the list (I noticed if i use the ‘delete a list of things’ option in Workflows>Data then it deletes them before the API starts)
I hope this is not a stupid question but will these be considered one workflow or will it counts as a workflow per wishlist item?
I’d also like to know if it counts as an extra workflow run when you do this, or if it’s all part of the parent workflow that it’s called from?
To me, that’s the difference between it burning through my workflow allowance 21x faster or not. So pretty important to know. I can conduct a test tomorrow to find out, but if anyone knows, it’ll save me quite a while to set this up and try it out to check if it’s a useable method for me.
Hi @james.k.grover
I just did a few tests and it shows that it used a workflow for each of the list items + 1. I moved three lists, two with 3 items and one with 4 items. In both the 3 item lists it used 4 workflows and on the 4 item list it used 5.
This is not exactly great news, my understanding was that a workflow is calculated as a set of instructions on for instance a button click, everything you link to that one action is one workflow. In my case this entire API ‘trigger’ is linked to one button click.
I build a WF counter and limit my users to x amount of workflows per month, this is going make that poor counter work overtime.
Do you have an upper limit on how many things to create?
Ugly hack follows …
If it is small enough, say 20 items, could put 20 workflow actions “create thing”, getting the values from a position in a list, and on each one a condition comparing to a count which determines if the thing is created.
I ended up just using “copy a list of things”, then using “make changes to a list of things” to tag each with a number according to their list position. But my issue was slightly different than OP’s. I wasn’t trying to change the type of thing, only the parent.
The issue as described in OP… i’d suggest making a thing of type ITEM which is always the same, then making WishlistItem a list of ITEMS, and ShoppingCartItem also a list of ITEMS. Then the problem can be solved the same way i did (i.e. all in one workflow)
Has anyone done this where…
You have a “QUOTE” and want to have the user click a button [convert to “ORDER”] where it would copy pretty much all the “QUOTE” fields but create a new thing in the “ORDER” table and assign it a new order number.
The same thing would happen when the order is complete, to assign it to a a new “INVOICE”
Would I have 3 tables for “LINE ITEMS” one for quotes, orders and invoices? And copy those as well?
That really depends on your needs. There are a number of ways to handle this type of design. If you are really duplicating all the information two extra times, you could consider one of the following options.
Add a “Status” field to your table and make Quote, Order and Invoice be statuses. You would probably have fields that Order needed that quote didn’t and fields that invoice needs and order didn’t so you would just have extra empty field for records in the earlier statuses.
You can create the Quote object/thing with all the fields you need. You then create an Order object/thing that has a field called “quote” that holds a quote thing in it. The Order thing would have the extra fields orders need. You then create an Invoice thing and give it a field called Order that hold an order thing. Make sense? This is likely the better way, especially with Bubble, but without knowing all your needs it is a guess.
Hey Marc,
Thanks for your response.
I guess the main two reasons I’m thinking of would be; 1. Having a record of the original quote and 2. being able to have separate numbering for the 3 things. I like what you suggested in option 2 however sometimes we have a quote and the customer may only order 2 out of the 4 line items at that time. I may be over my head, thinking I could make all this work in real life like it does in my head.
Solving for a partial order is easy enough. Add a status to each line item in the quote. For things they actually order, set the status to “ordered” and for those they don’t set the status to “declined” or whatever you want.