Client script for child table

Hi @umarless,

Please check the syntax.

DocType → Parent DocType
your_child_table_fieldname → Set your child table field name
d.amount → Set your amount field name which is in the child table
total_paid_amount → Set your parent total field name.

frappe.ui.form.on('DocType',  {
    validate: function(frm) {
        var total_paid_amt = 0;
        $.each(frm.doc.your_child_table_fieldname,  function(i,  d) {
            amt += flt(d.amount);
        });
        frm.set_value("total_paid_amount", amt);
    } 
});

Please set the doctype, child table field name, and other field names accordingly.

Reference:

I hope this helps.
Thank You!

1 Like