How to get the calculated values of child table on to a field in a parent doctype

Hello Everyone,

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.

Can anyone help me on this script?

Thanks & Regards,

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;


Hi Lokesh,

I have edited with your code as follows.

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;


It’s not working.

I’m not sure whether the editing is proper or not.

Please help.

items_table1 should be table-field on your parent doctype, that you have linked with your child.


I couldn’t understand, can you please explain briefly.

I’m not good at scripts.

Do you have access to the Python file of this doctype you created ?


I am able to calculate the values of child tables from the script mentioned above, but I want some calculation for the parent field 'Total".

use cur_frm.doc.items_table
instead of items table1

Tried using this, but still not working.

Got error while reloading.

where you are writing this code?

These codes are in parent doctype

It looks like typo error. Could you please share full your script from the Script field?

Here is the custom script.

please try to change this part




I tried changing that part, but I got this error.

please change

var temp = cur_frm.doc.items_table1;

I have tried that too, but still getting the same error.