Deluge Script

Zoho Creator Subform Calculation

This is the example of how to Get values into subform and how to auto calculate total amount based on the Qty and Discount Price using Deluge Script in Subform – Zoho Creator

  1. When record is created/ Edited – On User Select Product Name in Subform.
if(Item_Details.Product_Name != null)
{
	for each  itemlist in Item_Details
	{
		Items = Items[ID == itemlist.Item_Name];
		itemlist.SKU=Items.SKU;
		itemlist.Actual_Stock=Items.Actual_Stock;
		itemlist.Retail_Price=Items.Retail_Price;
		itemlist.Wholesale_Price=Items.Wholesale_Price;
		itemlist.Tyre_Size=Items.Tyre_Size;
		itemlist.Brand_Name=Items.Brand_Name;
		if(row.Qty != null)
		{
			row.Discount=Items.Discount * row.Qty;
		}
	}
}

2. When record is Edited/Created – on user input QTY in Subform.

if(row.Qty != null)
{
	Items = Items[ID == row.Item_Name];
	if(row.Qty != null)
	{
		row.Discount=Items.Discount * row.Qty;
		row.Retail_Price=Items.Retail_Price;
		row.Total_Price=row.Retail_Price * row.Qty - row.Discount;
	}
	input.Total = 0;
	for each  new in Item_Details
	{
		input.Total = input.Total + new.Total_Price;
	}
	input.GST = input.Total * 18%;
	input.Subtotal_Before_GST = input.Total - input.GST;
}

3. When record is created/ Edited – On User Select Discount in Subform.

Items = Items[ID == row.Item_Name];
if(row.Qty != null)
{
		row.Retail_Price=Items.Retail_Price;
		row.Total_Price=row.Retail_Price * row.Qty - row.Discount;
	}
	input.Total = 0;
	for each  new in Item_Details
	{
		input.Total = input.Total + new.Total_Price;
	}
	input.GST = input.Total * 18%;
	input.Subtotal_Before_GST = input.Total - input.GST;
}

Leave a Comment