Calculations while adding new record

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

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:

3 Likes

Thank you

1 Like

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.

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.

3 Likes

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