Forum Academy Marketplace Showcase Pricing Features

Can a list have multiple copies of the same entry?

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

Create a new table that has the multiplier and the material ?

So instead of Onions, Onions … you have 2 x Onions (sorry for the oversimilfication !_)

Bubble doesn’t have arrays.

So what I’ve done in similar circumstances is create an “array” table in the database. Like this:

Thing 1

  • field
  • field
  • field

Thing 1 array

  • Thing 1
  • amount

So if you wanted a list of Thing 1’s with multiples you’d create new Thing 1 arrays and put the multiples in the “amount” field. Then save the list of Thing 1 arrays.

This means when you try to search you’ll have a harder time because the data is split across multiple tables. The search function will only let you search by the fields on the thing you’re searching for. I’ve actually duplicated a lot of data. I just record it in a couple different places when it changes so that I can look it up either by array or by the duplicate field on another table. You can also use a trick where you set a search field to something like “[field-whatever] [is in/isn’t in] [search for thing-1-array]”. The nested search happens first and its results act as a filter for the parent search.

I tried to get around it (and excuse me im a newb) by doing the following

Created a new entry in the TASK database called MATERIALS

to put it in perspective
TASK
Name = bake a loaf of bread
Materials = MATERIALS

MATERIALS
material 1 = dough
material 2 = flour

the list of TASK-MATERIALS is now displayed on my page as a repeating group with a little X icon to delete the MATERIAL and a + and - to add and subtract more or less of the item.

I now have the problem (an im a newb at databases so i’m sure you’ll chuckle) but when I delete the material in TASK it deletes the material from TASK-MATERIAL but also deletes the main copy of the material in MATERIALS

any advice

**edit - which is not what I want, I want to keep the database of materials secure

If you delete a record Bubble will also remove it from any lists it’s in.

You’re probably deleting the record itself instead of removing it from the list.

To remove something from a list use the “make changes to a thing” action. Select the field with the list and make changes to that field.

so again a silly question.
Is the MATERIALS entry in TASK-MATERIALS it’s own entry or just a link.

In perspective
if I have multiple tasks say
TASKS
name: BAKING BREAD
materials: MATERIALS

name: COOKING COOKIES
materials: MATERIALS

MATERIALS
name: DOUGH
amount: 500

name: FLOUR
amount: 300

and both
BAKING BREAD-MATERIALS contains dough
COOKING COOKIES contains dough

if I change the amount in BAKING BREAD-MATERIALS will it affect COOKING COOKING-MATERIALS

the same as when I deleted the item it deleted it from the main database

BTW thanks champion for the remove tip it worked perfectly

OK dont worry found the answer :frowning:
They’re linked rather than a copy.

Is there a way I can copy MATERIALS-DOUGH from the database MATERIALS into the TASK-MATERIALS easily?

edit* and if I did this would I have trouble getting metrics in future. say when I try to produce a graph for how much dough I used in each month of the year?

You don’t want to make a copy of the Material record because then if you change the original Material record the copy will still be old. For example, if you edit the record to fix a spelling mistake (change “hamer” to hammer" or whatever).

Also, if you want to get metrics later, then you want a bunch of references to the same thing. That way they’re easy to count. If you have independent copies, none of them linked to each other, then all you can do is count words (like count how many things have the word “hammer” in them, and how many things have “hamer”, and add them together).