# How to Prevent Inventory Stock from Going Negative

**URL:** https://community.glideapps.com/t/how-to-prevent-inventory-stock-from-going-negative/80962
**Category:** Ask for Help
**Created:** [March 25, 2025, 10:41pm UTC](https://community.glideapps.com/t/how-to-prevent-inventory-stock-from-going-negative/80962 "2025-03-25T22:41:38Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Mehmet\_Karaca](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mehmet_karaca/32/84984_2.png) [@Mehmet\_Karaca](https://community.glideapps.com/u/Mehmet_Karaca)
#### Post date: [March 25, 2025, 10:41pm UTC](https://community.glideapps.com/t/how-to-prevent-inventory-stock-from-going-negative/80962/1 "2025-03-25T22:41:38Z")

</div>

Hello fellow Gliders,

I’m facing a challenge in my project and could really use some help.

I have two tables: **Work Orders** and **Stock (Inventory)**. I want to ensure that stock quantities never go negative. For example, if a product has 9 units in stock, users should not be able to add more than 9 of that product to a work order.

I tried linking the **Quantity (Number) Component** to the Stock table, but it only allows selection from the Work Orders table/column.

One potential solution I considered was using an **IF-Then-Else** column to detect when a product’s quantity reaches zero and prevent further additions. However, this approach doesn’t work if the remaining stock is, say, 4, and user tries to add 5 units at once—since the check only triggers when the stock hits zero, it wouldn’t prevent that action in advance.

Any suggestions on how to handle this? Thanks for your time!

 ![stock](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/e/2/e2760b96eac6c0d70cf185d6da0262e95f68b59f.png)

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [March 26, 2025, 12:14am UTC](https://community.glideapps.com/t/how-to-prevent-inventory-stock-from-going-negative/80962/2 "2025-03-26T00:14:54Z")

</div>

You are trying to lookup the “max value” in a form, that won’t happen naturally due to the sandbox nature of the form.

You have 2 ways to go here:

- First method: For the Product ID choice, create a column in your users table for it, and write to that column instead of the Product ID in your Work Orders table. Then, add a special value in your form to write User Profiles \> Product ID to the Work Orders.

This allows you to access the Product ID value whilst still inside the form. From that value, you can create a relation & lookup to retrieve the max value allowed for the quantity.

- Second method: Create a custom form.

> [@How do I create a custom form?](https://community.glideapps.com/t/how-do-i-create-a-custom-form/25014):
>
> I’m just dropping this here so I have something to refer people to when they ask. This is a simple concept app (copyable), that demonstrates the following techniques: Building custom forms for adding and editing list items (as an alternative to the native forms provided by Glide) Preventing duplicate new entries using [User Specific Columns](https://docs.glideapps.com/all/reference/data-editor/user-specific-columns) and [Relations](https://docs.glideapps.com/all/reference/data-editor/computed-columns/relation-column) Enforcing mandatory input items The use of visibility conditions and user specific booleans to control user flow There is nothing particular…

---

<div class="post-metadata">

### Author: ![Mehmet\_Karaca](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mehmet_karaca/32/84984_2.png) [@Mehmet\_Karaca](https://community.glideapps.com/u/Mehmet_Karaca)
#### Post date: [March 28, 2025, 8:36pm UTC](https://community.glideapps.com/t/how-to-prevent-inventory-stock-from-going-negative/80962/3 "2025-03-28T20:36:44Z")

</div>

## Here is How I Solved The Above Problem.

### Solution

#### 1. **Using a “Show New Screen” Instead of a Form Page**

Instead of using a form page, I switched to a “Show New Screen” approach. This was crucial because, in a new screen, data updates instantly as users enter values.

#### 2. **Storing Temporary Data in the User Table**

To track selections in real time, I created temporary columns in the **User** table. As soon as a user selected a product, its **Product ID** was stored in the User table.

#### 3. **Fetching Available Stock Dynamically**

I created a **relation** from the User table to the Stock table based on the selected **Product ID** and then used a **lookup** column to fetch the available stock quantity. This allowed me to dynamically set the **maximum allowable value** in the quantity input field.

#### 4. **Preventing Over-Selection with a Workflow Condition**

While setting a max value helped, users could still bypass it by manually entering a larger number and clicking submit. To solve this, I added a **workflow condition** :

- If the entered quantity exceeds the available stock, the submission is blocked, and an error notification appears.
- If the quantity is valid, the process continues as normal.

### Conclusion

By using the **Show New Screen** instead of a form, storing temporary selections in the **User table** , fetching stock availability via **relations and lookups** , and enforcing a **workflow condition** , I successfully prevented stock from going negative in work orders.

I hope this helps anyone facing a similar issue! Let me know if you have any questions

---

<div class="post-metadata">

### Author: ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)
#### Post date: [March 29, 2025, 5:33am UTC](https://community.glideapps.com/t/how-to-prevent-inventory-stock-from-going-negative/80962/4 "2025-03-29T05:33:23Z")

</div>

> [@Mehmet\_Karaca](#):
>
> While setting a max value helped, users could still bypass it by manually entering a larger number and clicking submit. To solve this, I added a **workflow condition** :
> 
> - If the entered quantity exceeds the available stock, the submission is blocked, and an error notification appears.

You can just not allow the submission button to show at all when this doesn’t satisfy I think, and show a hint error.
