Can a list have multiple copies of the same entry?

So, I just sort of assumed that a list wouldn’t have any trouble just adding new entries, but I’m having trouble.

I want to create an arbitrarily long list from a small set of options, but it seems like the list will only hold one copy of each option, with the minor caveat that sometimes there’s an empty item in the list.

For example, if my set of options is A, B, C, D I want to make a list like D, D, D, A, B, D, C, A, D, D. Is that possible? So far it hasn’t worked for things or images.

Here’s a shot of the database. Each of these lists was created by selecting from a dropdown. Building the list works perfectly, except that it won’t let me add more than one copy of each dropdown option.

I don’t think you can add multiple copies of the same entry, since each entry has its own unique ID - that would mean multiple Things with the same unique ID. Instead, you could set something up where once an entry is selected from the dropdown, and a button is pressed to add to the User’s List of entries, a new type of Thing is created (which has the same fields as the selected, dropdown Thing - as well as a parent field which stores the selected dropdown Thing). Then you could have many of the same Things within a User’s list, and each Thing would still be connected to that dropdown parent Entry. Are the dropdown values only one field of Text (A, B, C or D)?

So each entry in the list has to have its own unique ID then; the list itself doesn’t create its own ID system like an array would. So use the list of options as templates, and actually create a new copy to put into the list? Something like this:

options
ID:1 - name:red - image:apple
ID:2 - name:yellow - image:banana
ID:3 - name:blue - image:plum

step1 action create a new thing
name = option’s name
image = option’s image

step 2 add the result of step 1 to the list

Maybe delete the copies after finishing work with them? Is that important? We get charged for workflows more than for storage, right? Is it less of a burden on Bubble to just let the working copies pile up than to run the workflows necessary to garbage collect them?

What are you hoping to achieve in your app? Or, what are Users selecting and putting into a list?

I was thinking that you had:

Dropdown Options (Type: Fruit):
unique id: 1, red, apple
unique id: 2, yellow, banana
unique id: 3, blue, plum

So let’s say the User selects apple twice and banana once (you want them all stored separately into a List):
Step 1 --> Create a new (Type: User_Fruit)
ParentFruit: DropdownSelection 1, creator (built-in): Current User
ParentFruit: DropdownSelection 1, creator (built-in): Current User
ParentFruit DropdownSelection 2, creator (built-in): Current User

Are you trying to have multiple items in the list in order to increase a quantity of the entry? If so, you could do:

Create a new (User_Fruit)
ParentFruit: (dropdown selection)
Quantity: number that the User enters
Creator: Current User (built-in)

Yes, we are only charged by number of workflows; it’s up to you on whether you want to keep the data or delete it.

I’m trying to be generic so that the answer applies to more than one use case. In general, what I’m asking is how to make a list of database things that just appends the new addition to the end of the list.

Specifically, what I’m playing around with is a way to hack a canvas into Bubble so that my users an “draw” by selecting images from a list and dragging them around to create a drawing. It would be nice if they could make multiple copies of the same image, rather than being limited to one copy of each image.

One way I thought of to do it was to build a fixed repeating group with like X columns and Y rows to simulate a grid. I figured if the grid was small enough (if there were enough columns and rows) it would work like a canvas. One way to control the drawing would be to have a list with as many items as there are “pixels” (cells) in the repeating group. At the time I assumed a list could have multiple references to the same database thing. Apparently it doesn’t work that way.

That misunderstanding highlights the fact that nowhere in the documentation (or on the forum that I can find) is there an explanation of what exactly a list field is, how the data is stored, and what it’s capabilities/limitations are. So I figured I’d try to get more details on that.

I think you would need to create a new Thing each time and add a position field to the data type, because even if you were to have the same Thing multiple times within a list, each thing would need to have the custom position of where it belongs within the repeating group - determined by where each individual Users drags and drops the item

Agreed, you could copy things to make this work, but that seems like it could also get complicated. Have another data type that references the image (so it exists once and once only) and store the additional data about the position on that.

Another example of many-to-many.

1 Like

Maybe I am misunderstanding the question being asked here, but I believe am having the same problem as the OP.

I am trying to create an invoicing system. I can get items to populate just fine but saving them to the database. The result of the invoicing system looks like this:

Now, these numbers are saved under the thing ‘products’. each product has a number associated with it which is the price (one field), it’s name (dress shirt, shorts, etc.), category, (laundry, dry cleaning, wash & fold, etc), the quantity (how many of these products we are cleaning for a customer) and the total cost for cleaning that product (total). The list is generated by adding a quantity of +1 for each product being cleaned, and saved under the quantity field. In this example, 3 is the quantity and pants is the name.

Once this invoice is finished, I need to save this list to a new thing called ‘orders’. The goal being that each thing in the database of ‘orders’ is a request that a customer has made, with an itemization of the products that we had cleaned for them on that order.

Now, the problem that I am running into is that I have 3 products with the quantity of 3. So I NEED a list to be saved that looks like ‘3, 3, 3’ so that when I review the order later, I can see 3 pants, 3 shorts, 3 polos. Instead, the number 3 is only saved once, not 3 times.

Is there a way to get around this?

Hi @jameslusk,

I think you’re very close with a few adjustments needed to your data structure. Am I correct in assuming that Products are set items (like Inventory) that you offer as things available for applying a service (laundry, dry cleaning, etc.)? If so, you need to remove the quantity and total fields out of there. Please review the below data structure and let me know if I misunderstood something, but this should allow you to create the invoicing system you need:

Product

  • Price (number)
  • Name (text)
  • Category (text)

Line Item

  • Product (Product)
  • Quantity (number)
  • Total Cost (number)

Order

  • Customer Name (text)
  • Customer Phone (text)
  • Line Items (List of Line Items)
  • Total Cost (number… “This Order’s Line Items’ Total Cost :sum” )

Every time a customer fills out an order, they create a line item so that quantities and total costs can be associated independently for each Product. The Line Item itself should be a separate entity from the Product because different customers will have different quantities.

Add each Line Item to the Customer’s Order… to the Line Items list field.

This list can be displayed in a repeating group (type: Line Item, source: Order’s Line Items). Within each cell you can add text elements to display “Current Cell Line Item’s Quantity” and name, etc. Here you’ll be able to see the breakdown you’re asking for.

Let me know if you have any questions.


Gaby | Coaching Bubble

1 Like

The issue I am having is relating fields to ‘things’ in another data base. As noted below, you recommended structuring my database as such:

The problem that I am running into is relating the items together as suggested. For example, the ‘line item’ thing should have a field which points to the product that relates to that line item. But I can’t find any way to get a new thing to create, and populate that field with any ‘product’ thing from another database.

I have tried setting the field time to product. However, the workflow editor does not have an option to save a product itself there, or just it’s unique ID. Doing a ‘search for’ option yields an error of ‘this field should be a product, but instead it’s a list of texts’.

In the line item example, this comes up again in another way. In the line item, I am going to have to create the ‘total’ for that line item. This total is calculated by multiplying the price of the ‘product’ in question, by the ‘quantity’ of the line item. Not sure how to get the one specific number in there. I could add constraints for category and name, but that seems to yield an error of ‘this is a list when it should be a number’ kind of thing.

Thank you Gabby and everyone else, very excited this is progressing well!

I guess I need to see a little more of your structure to help with your workflow. But let’s say for example that you have a repeating group of products for the user to choose from…plus an input field for them to indicate quantity…

When button is clicked > create new line item: product = current cell’s product, quantity = input’s value > make a change to Order: line items add result of step 1 (the step that created the line item)

Does this help? Feel free to share a link.

Yes that does. I guess the issue that I am running into is that I am building out a test before I actually did anything within our app. Just so that way I don’t mess anything important up if I can’t get it working. The barebones structure of the test app is missing some of those things like a repeating group. However, that is much more realistic since that is how it will work in the actual app. Let me try getting it set up that way, and see how it goes from there.

Thank you so much!

1 Like

This is brilliant, and really helpful, thank you so much! I guess the one issue I am running into is usability. Below are screens and a link to what I have set up in the test app. This app is rather simple compared to what I will have to use later with many different categories of things, and potentially long lists.

From what I am understanding of your suggestion, is that each line in the repeating group will need to have it’s own ‘save’ button. If there are 30 different lines, it can be cumbersome and time consuming to hit save that many times.

The functionality I’d like to get to is having one button saved outside of the repeating group, which saves the information inside of it. Currently, I am not seeing a function in the work flows for creating multiple things at once.

In this image, the button in the cell is set to add +1 to the product, which will give us the quantity:

How it looks in action:

I can’t get the ‘save order’ button to create a new thing in the work flows. This is getting back to the original problem in my post above: Once I have this list, how to save it? Before it was as a list, but I think your solution of having things of type ‘line item’ is a much better solution. However, I still have a list, and would like to click one button to get the individual line items saved.

thank you so much for your feedback!!

Working on tinkering with the ‘schedule and action’ function as described in this post to see if it might be a solution. Though at an initial glance, this seems a bit complex as well.

App link:

Actually, I just realized that since I am clicking the button anyway, it is essentially creating the new line item any way.

Maybe what I can do instead is get it to save a new line item. Though I could see a potential conflict. I wouldn’t want to create a line item every time. Otherwise, if I click the button 5 times, there would be 5 line items for 1 through 5.

This gets me thinking about a number of other solutions. Would it be possible to check if this line item had already been created each button click, and if it had, ‘edit a thing’ instead of ‘create a new thing’…

Maybe having that list of 1-5 isn’t ideal, but not so bad either. I could display only the ‘:max’, for readability, but that those multiple entries could kind of serve as a log of button presses too.

Sorry, this post is mostly me thinking out loud/ in print :0)

Ok… check out your test page. I want you to study it, haha. There are so many ways to do this functionality. Some of the nuances are going to depend on how you want your UX to go, so keep in mind that this isn’t the only way.

You asked great questions about how to save or create something based off a single button click. The quick answer to that is to use “Schedule an API workflow on a list” - but what I’ve created in your test page avoids that in case this route works.

Right now this is what I did… the purple box is your list of orders. Click the green button to create a new order, which will display its details in the green box below. Add products with indicated quantities to the order from the blue box. Adding a product will create a new line item and then add that item to the Order’s list of line items. From there, you can edit the line item’s quantity inside the order section. You can also remove a line item altogether.

Study everything going on there and come at me with more questions at any time :slight_smile:


Gaby | Coaching Bubble

1 Like

Gaby, this is so super awesome. Really disappointed that the forum only allows the awarding of one heart for this help. Thank you so much. It has mad a great improvement in my understanding.

First, related to functionality. If you go back to the app, you will see that I have made changes to better reflect the reality of what we will be working with.

So, on to questions.

  1. add to order button: search for line items: first item. I am not sure what is going on here for the workflows. Why first item, and why doesn’t that always do the same product/line item?

  2. ‘when input quantity value’s changed’ This workflow seems to suggest that it will change the ‘quantity’ if it gets changed by typing manually. is this correct? I didn’t notice this till just now, and it seemed like the functionality wasn’t working as intended, but maybe i wasn’t looking for it at the time because I didn’t know what it did. Is this correct? simply typing a new number and hitting enter will change the value in the database? I ask because the value seems to update, but the total does not. What I mean by total is the grand total for the entire order. The total for the individual ‘line item’ updates, but the order total does not.

  3. usability: typing in quantifies or buttons for +/-1? We will have to process orders as quickly as possibly, and removing key strokes seems to be the best, as our current SAS does it this way. Do you have any thoughts on the matter.

  4. Generating invoices. Basically, all we have to do now is to generate an email that has the data in the display group for customers. Is there a way of doing this without having a repaint group in an email, but it still being legible to users?

  5. Breaking down lists quickly. The test page has become a fairly functional prototype. One thing I do see that will be helpful, is updating multiple items in a list at once. Do you know of any forum pages which describe this process well? I am not sure that I have seen any, and the ones that are there have example apps which have since been deleted.

Again, thank you so much for this. It has been a hurdle trying to figure our way around, and the lessons learned will apply to several of our next big hurdles. For one example, customers can request laundry ‘pickups’ (database thing) through the app. But, given the route to illustrated to go from order creation, to adding line items, I can see how to fit that into this current process, I think. I don’t have it completely conceptualized, but I am sure I can see away there.

However, the biggest hurdle is going to be payments for customers. Currently, we are using stripe. Which is fine if all of our customers have signed up through our app. However, 80% of them put their CC info in through our other SAS. So we have their payment info, but getting access to that through our app looks like it is going to be the biggest hurdle. It seems as if it will require an API connection. If you have any suggestions for getting this accomplished, I am open for receiving them.

The other issue is getting customers from our database into Sendgrid’s for company wide communications. This is mostly just rhetorical thinking through of our next steps. But Bubble and the community is making it possible.

Thank you again!

Hey @jameslusk, these are great questions!

  1. This action is so that you don’t add a product multiple times to the same order. You just want 1 of each product desired with a quantity. So when we click Add to Order, it looks for the first Line Item that is both for that Cell’s Product and for the Current Order. Only 1 Line Item should ever match it, so we return the :first item to update its quantity, or if it doesn’t exist - create the line item (which is why “Create if the thing doesn’t exist” is checked).

An alternative around this is to simply remove the Add to Order button if that product already exists in the Order so that quantity management simply happens in the order area instead.

  1. Yes, you followed the logic correctly and I just forgot to add the Total Price field in the Line Item workflow. I added it, so should be good now :slight_smile:

3)This is totally up to how you guys will use the app. I think +/- buttons work just as well, but my argument against it is what if you have a high quantity number like 10… clicking the + 10 times is more cumbersome than typing in 10. You COULD offer both!

  1. From what I can see going on in this test page, you may be better off generating and emailing a proper PDF file (you can use SelectPDF plugin… paid service). It would be a cleaner record for you and your customers to keep, I think. Including a list of line items with all that data in an email could get very tricky because it’s all dynamic with nested lists. I’ve gotten around this in other apps by creating a separate Thing to hold the proper formatting of text, but it’s a bit of a workaround, and I still think PDFs are the way to go.

  2. Update multiple items how? Like update the quantity for all Line Items by the same amount? Expand more on what you want to achieve and I’ll help you come up with a solution.

  3. What is your SAS?

  4. I’m sure with Sendgrid’s API you can update the database or send out campaigns from the Bubble App via API as well. Their API is pretty extensive.

1 Like

This is great.

  1. that makes sense, thank you!

  2. I will need to see what you added for the total. I had added that in there as well, and it was odd. When I typed and hit enter, the order total did not add up. But, if I hit the +/- button, the total would update as if 1 was +/- from the quantity from the quantity typed in the total.

  3. as I was testing out that page, buttons and typed entry seemed to have merit. I was even thinking +/- 10 as well as an option. Mostly because after a couple button clicks, the app refreshes, and half the clicks get missed.

4)PDF was something I looked into a while ago for emails. However, APIs kill me. Haven’t quite gotten the debugger figured out either to diagnose what’s going on. Also, select PDF seemed kind of expensive. I found another PDF API, with much more reasonable prices, at base allowing for 500 conversations a month for free or something like that.

Just saw another forum post where a guy converted all his fields into another field called ‘string’ of that thing. in this case, I think that probably would be a line items. this ‘string’ field will have all the proper information and formatting. Then, hopefully adding the ‘line_break’ function to put that field’s list it into rows. Just got this working, and it seems sufficient for now. PDF would be ideal, but I wanna stop paying for my other SAS quick, so this seems quick and doable for now.

  1. so updating multiple items: what I mean is update a field in each item, with 1 button click. So, for example, the orders box in the test app now has many orders that i have created. And each one has a button titled ‘cleaned’ which marks the order as cleaned, removes it from that orders box, and sends it to the deliveries (found on the pickups page).

In this case, let’s say I have 5 orders to mark as cleaned. Instead of clicking 5 different buttons, clicking one which updates all 5 of those orders. While nice, I don’t see this as a deal breaker yet, but will need it when we start processing 100-500 orders a day.

6). Our current SAS is called cleancloud. On my phone so can’t link now, but it is at ‘cleancloudapp’.

It is the best in the industry, but still clumbsy. We need better to provide the level of service we want to our customers.

7). I am sure. Just another thing to get done sending it to send grid.

Thank you again!

Yes it’s possible. No, you don’t need to create a new thing. I’ve created the pixels that you’re describing with state. Lemme know if you have trouble!

Hey guys, i’m trying to look at the example app that was attached but it wont open. I do need some help tho

I have a similar problem to above.

Basically I have a job card, on that card there is a list of materials needed and a list of all the materials available. I have the list set up so as I can add an item from all the materials to the job materials.

The job materials is a list of text in the database entry for the particular job card. My drama is I cant add more that one of each material. I click the add material and it adds one copy then wont add more.

Also if I add multiple of the same items directly into the database it still only displays one, when I click remove item it removes all entries from the database.

Any ideas how I can implement the above or any other solutions so as I can multiple materials of the same type in my job