How to get total of amount from table

Hey @GhadaEbrahim,

I think, you not proper understand.

Plesae match with field and doctype.

Supplier → Parent DocType
frm.doc.payment_details → Child Table field name in Parent DocType
d.collected_amount → Child table field name which you want to calculate in parent field.
debt_collected_amount → Parent Doctype field name.

frappe.ui.form.on('Supplier',  {
    validate: function(frm) {
        var dca = 0;
        $.each(frm.doc.payment_details,  function(i,  d) {
            dca += flt(d.collected_amount);
        });
        frm.set_value("debt_collected_amount", dca);
    } 
});

I hope this helps.
Thank You!

2 Likes