How to add the number of unit for each item and the "out of stock" message for my e-commerce app

Hi all,

I’m trying to build my first app on glide to sell some second hand products :slight_smile:
I have one unit per product for the moment and I would like to make sure the same product will not be sold twice ! So here are my question:
1 - How can i link the number of units for each product ?
2 - How can i make sure to add the message “out of stock” when the product is sold?

(My data is extracted from a google sheet)

Thanks in advance so so so much for your support!!!
You’d save my day,

1 Like

I imagine you have a table/spreadsheet of available items. Let’s call this table “Items”.

  • Add a RowID column to this table that will serve as the “Item ID”
  • Add a number column to this table called “Quantity”. Since you said there is only one unit per item, you’d write the value 1 for each item

In Glide…

  1. When someone claims/buys a product, add a new row to a new table called “Purchases” (or the like)

    • When this row is added, be sure to pass along the Item ID (I recommend using Row ID in the “Items” table)
  2. Create a relation column (match multiple) in the “Items” table that matches the Row ID with the Item ID column in the “Purchases” table

  3. Create a rollup column (let’s title it “purchaseCount”) in the “Items” table that’s sourced from the multiple relation in step 2. This will give a count of how many times that item was purchased (how many rows for that item are in the “Purchases” table)

  4. Create a math column in the “Items” table (let’s title it “remaining”) that subtracts purchaseCount from Quantity. This will result in the number of items remaining for purchase.

  5. On the Details screen for each item, add visibility logic to components to prevent the user from purchasing the item when "remaining" is less than 1.

    • Add this condition to a hint text component to show a message that this item is “out of stock”
    • Add the reverse condition ("remaining" is greater than 0) to the button they use to purchase the item.

I do something similar here:


Wow…thank you so much for your help !!! I did all the set up you suggested and it works. Amazing :).

I have one (last) additional question: Is it possible to make sure the Item ID will be automatically added in the table “Purchases” as soon as someone will buy a product? - or do i need do it manually as soon as a purchase is done ?

Thank you so much for your precious help

If you’re using a form to write the new row to the purchases sheet, you can pass the RowID automatically by using Screen Columns.

The UI is outdated in the video, but the process is identical:


Thanks for your quick reply ! I tried to follow the video but i don’t have the ability to put a destination sheet with the buy button as shown for the form button in the video. I only get the product info (i have the starter project subscription).

Thanks again for your help,

Ah…you’re using the Buy Button…yeah, it’s a bit trickier then. Are you using Google Sheets or Glide Tables?

Google Sheets !

Do you see an “App: Sales” sheet in your spreadsheet?

Yes, thank you!
Indeed, I found out that the Item ID was appearing in the “App: Sales” and created the relation column and the rollup column with the instructions quoted below.
I am now able to see when a product is out of stock on my app or not.
Thank you both !!!


I’m not sure you have gone past that step yet or not, but you must create a “mirror” sheet by using a formula to make Glide see the “App: Sales” sheet.