# Calculations while adding new record

**URL:** <https://community.glideapps.com/t/calculations-while-adding-new-record/46583>\
**Category:** Ask for Help\
**Created:** [August 12, 2022, 7:22am UTC](https://community.glideapps.com/t/calculations-while-adding-new-record/46583 "2022-08-12T07:22:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jayadevan\_V](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jayadevan_v/32/46103_2.png) [@Jayadevan\_V](https://community.glideapps.com/u/Jayadevan_V)\
**Post date:** [August 12, 2022, 7:22am UTC](https://community.glideapps.com/t/calculations-while-adding-new-record/46583/1 "2022-08-12T07:22:08Z")

</div>

Hi  
I am new to glideapps. I have created a form to add records. While adding new records I need to calculate values based on certain conditions. For Example

Stock Master

1. Item Name
2. Balance Qty
3. Price

Stock Issue

1. Date
2. Item Name
3. Issue Qty

Issue Qty should be validated against Balance Qty.  
If Issue Qty \> Item master-\>Balance Qty then Message “Enough stock not available”  
If Issue Qty \< Balance qty then calculate Issue value as Qty \* Price in Item master.

Please help me to understand how it works.

Regards,  
Jayadevan V

---

<div class="post-metadata">

**Author:** ![nathanaelb](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nathanaelb/32/43079_2.png) [@nathanaelb](https://community.glideapps.com/u/nathanaelb)\
**Post date:** [August 12, 2022, 7:42am UTC](https://community.glideapps.com/t/calculations-while-adding-new-record/46583/2 "2022-08-12T07:42:19Z")

</div>

I think you will need to create a **custom form**.

You cannot achieve what you want with a native form, since with a native form the data can only be computed _after_ it is submitted, whereas you need to compute it _before_.

Darren explains custom forms here:

> [@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 particula…

---

<div class="post-metadata">

**Author:** ![Jayadevan\_V](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jayadevan_v/32/46103_2.png) [@Jayadevan\_V](https://community.glideapps.com/u/Jayadevan_V)\
**Post date:** [August 12, 2022, 11:26am UTC](https://community.glideapps.com/t/calculations-while-adding-new-record/46583/3 "2022-08-12T11:26:23Z")

</div>

Thank you

---

<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:** [August 12, 2022, 11:50pm UTC](https://community.glideapps.com/t/calculations-while-adding-new-record/46583/4 "2022-08-12T23:50:53Z")

</div>

To be clearer on your setup, assuming you’re adding a stock issue in your custom form.

- You would need to have 3 user-specific columns to store the date, item name and issue quantity. You might want to store the stock master’s ID instead of its “name”, if I understand you right (Item Name in Stock Issue is linked to Item Name in Stock Master).

- Add a relation to relate the stock ID back to the Stock Master table, then two lookups on top of that relation to retrieve the balance quantity and price of the stock in question.

- Show the “Enough stock not available” message if the input issue quantity \> lookup balance quantity.

- Allow submitting through an add row action if issue quantity \< balance quantity.

> [@Jayadevan\_V](#):
>
> calculate Issue value as Qty \* Price in Item master.

If you don’t need to show this in the same form screen then you can simply add a math column in the destination Stock Issue table with the input quantity and the lookup price.

---

<div class="post-metadata">

**Author:** ![Jayadevan\_V](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jayadevan_v/32/46103_2.png) [@Jayadevan\_V](https://community.glideapps.com/u/Jayadevan_V)\
**Post date:** [August 13, 2022, 1:53am UTC](https://community.glideapps.com/t/calculations-while-adding-new-record/46583/5 "2022-08-13T01:53:53Z")

</div>

Yes your understanding is correct but kindly give the steps to accomplish it.  
My doubts are

1. I hope the look up to be created in Data Editor ?
2. Show the Enough Stock not available - how to trigger this message, what is the component that can display message ?
3. On Submit-\>Add Row - shows all the columns, how do I give If condition ?  
if it return false how to stop submitting the record ?

Looking forward to get more guidance.  
Thanks  
Jay
