How to Properly Set Subforms in Zoho Creator: A Step-by-Step Guide

How to properly set Subforms in Zoho Creator Part 3

The first step is to have the Subtotal or Total field value in the Order Form. Normally this would be a currency field or decimal field if you need to consider 1 or more decimals into your calculations. If not you can also set it the field as a Numeric value field. Our example uses a currency field.


Second, you need to think about the places where the script to aggregate the rows needs to occur. In our case, there are several places. On Add Row, On Selecting a new Product, On Changing the Qty amount or the pricing. It is important that all scenarios are considered otherwise your calculations may not be properly aggregated if it encounters a scenario that you have not considered in your scripting yet.

Last but not least, the script below is ready for you to copy and paste into your application. Assuming of course that the field names of your Order Form are named exactly as our test application.



if ((row.Price !=  null)  &&  (row.Qty  !=  null))

{
    row.SubTotal = (row.Price  *  row.Qty);
}
t = 0.0;
if ((row.Price  !=  null)  &&  (row.Qty  !=  null))
{
    for each rec in Item_Details
    {
        t = (rec.SubTotal  +  t);
    }
}
input.Subtotal = t;

Do not hesitate to contact us if you have any questions. I would be more than glad to help you build an amazing online database application with Zoho Creator. Or check out our full Master Zoho Creator Subforms Course to learn more.

Check out other Zoho Creator blog posts that may help you understand how to build applications in Zoho Creator https://www.creatorscripts.com/blogs/zoho-creator/

    • Related Articles

    • How to properly set Subforms in Zoho Creator Part 1

      This is the most important step in the process of setting up your Zoho Creator database. A properly linked setup will enable your information to run smoothly and avoid wasting space ( MB ) First, you need to create at least 2 Forms. For example.- ...
    • How to properly set Subforms in Zoho Creator Part 2

      To build a robust Order form in Zoho Creator you need to be able to automatically "fetch" the information about a product and let the system pre-populates the subform with pre-existing data in the Products Table. First, you need to have a Products ...
    • How to define number of subform rows dynamically using script in Zoho Creator?

      It´s important to highlight that this post assumes you are already familiar with proper subform creation in Zoho Creator. If you are not please check out our Master Zoho Creator Subforms course in the url below before implementing this custom ...
    • Auto-Create Zoho Desk Tickets from Zoho Creator

      This script creates a Zoho Desk support ticket every time a record is submitted through a Zoho Creator form. It routes the ticket to a department based on a category picklist, carries the priority across, and writes the resulting ticket number and ID ...
    • Calculate Standard Deviation in Zoho Creator

      Averages hide the thing you usually want to know. Two products can sell the same annual volume while one ships steadily and the other spikes once a quarter — and only the second one wrecks your inventory planning. Standard deviation is what separates ...