Adding two numbers from two fields and placing it in another field

Hi , i used below code to add it is adding but it is not allowing to save quotation please give me any correction of the code.

// to add two fields
frappe.ui.form.on("Quotation","refresh",function(frm, cdt, cdn){
    var d = locals[cdt][cdn];
    frappe.model.set_value(cdt, cdn, "grand_total", d.total+ d.erection_total_rs);
    refresh_field("grand_total");
    });

Please say me what to change.
regards Aryan

any one can solve this, give me solution

set_value is refresh field automatically
you don’t need to add this refresh_field("grand_total");
And try to change the event to be onload

frappe.ui.form.on("Quotation","onload",function(frm, cdt, cdn){
    var d = locals[cdt][cdn];
    frappe.model.set_value(cdt, cdn, "grand_total", d.total+ d.erection_total_rs);
    });

thank you for reply
i used same code it is calculating but once i save, it is not adding there

That because there is another function override this action, you need to make your event on saving also to override it
you can use validate instead of refresh