I have created a parent doctype called “Vomax Cycle Order Form”.
This parent doctype contains a child table called “Items Table1”
I have written a custom script to calculate the fields of the child tables and it is working properly.
Also, there are other fields like “Shipping Charges” and “Total” in the parent doctype.
My requirement is, I want to display the sum of “Total Price” of the child table and the “Shipping Charges” to be calculated and displayed in the field called “Total”.
Formula is: Total= Total Price+Shipping Charges.
Please have a look at the screenshots below for parent doctype, child table doctype and the custom script for the child table calculation.
Hello sujay,
This is an example of calculating amount on child table. You can edit it accordingly and use this code on your validate event of parent doctype. var temp = cur_frm.doc.items; var sum = 0; for ( var i = 0; i < temp.length; i++) { var obj = temp[i]; var amount = obj.rate * obj.quantity; sum = sum + amount;
var temp = cur_frm.doc.items_table1;
var total = 0;
for ( var i = 0; i < temp.length; i++)
{
var obj = temp[i];
var total = obj.total_price + obj.shipping_charges;
sum = sum + total;
`}`
frm.set_value("total",sum)
It’s not working.
I’m not sure whether the editing is proper or not.