Custom Script to calculate total quanity on delivery note

Hi, All,

I am trying to calculate the total quantity on the delivery note , however, its not working
to show the total , but just on the customer field

  1. Custom field on delivery note ‘total_quanity’
  2. Create custom scripts Setup>custom script>Delivery Note>
    frappe.ui.form.on(“Delivery Note”, {
    validate: function(frm) {
    total_qty = 0;
    $.each(frm.doc.items || [], function(i, d) {
    total_qty += flt(d.qty);
    frm.set_value(“total_quantity”, total_qty);

Then i reload and look at my delivery note and its not working, may anyone help to advise
me what’s wrong and how to fix it ?

You may have to save the document to trigger validate

Yes, you are right, its working now, thanks