Sum fields in child table and show total in parent field

I want to sum fields in the child table (Sales Invoice Item) and show the total in the custom field in the parent (sales Invoice)

(calculate the discount amount in the sales invoice item)

Hi @msiam,

Please apply custom/client script.

frappe.ui.form.on('Sales Invoice',  {
    validate: function(frm) {
        ttl_itms_dicnt = 0;
        $.each(frm.doc.items,  function(i,  d) {
            ttl_itms_dicnt += flt(d.discount_amount);
        frm.doc.total_items_discount = ttl_itms_dicnt;

Please check your field name and set it according.
Then reload and check it.

Thank You!