Getting the Summary of the Amount in a Child Table

Hello,

I have a Child Table with tax_with_held fields and just want to get all the tax_with_held amounts and all the Total tax_with_held must be populate in a Parent Field name total_tax_with_held.

I’ve create a custom script but its not working.

Thanks

@sam_salvador You can use similar function as below
assuming that tax_with_held is a amount field in child table

cur_frm.cscript.tax_with_held = function(doc, dt, dn) {
calculate_total(doc,dt,dn)
}

var calculate_total = function(doc,dt,dn) {
var tbl_a = doc.child_table_field || [];
var grand_total = 0;

for(var i = 0; i < tbl_a.length; i++){

    grand_total += flt(tbl_a[i].tax_with_held);
    
}
cur_frm.set_value("total_tax_with_held",grand_total)

}

Hi @Deep,
But my tax_with_held field is a readonly field and its not working.

@sam_salvador If change event doesn’t work on read only field then you can add a button outside of child field and fire the same function on click of that button.