Automatically substract the value of 2 fields

Hello,

It is possible to substract the value of 2 fields?

Thanks!

cur_frm.set_value(“rest_piata”, cur_frm.doc.valoare - cur_frm.doc.discount);

Not Working

Custom Scirpt::

Fields

It only working if i click on ,Reload""

frappe.ui.form.on('Contracte', {
	refresh: function(frm) {
            //This will make sure they are are updated whenever the form reloads
		frm.set_value("rest_piata", cur_frm.doc.valoare - cur_frm.doc.discount);
	},
    valoare: function(frm) {
            //This will make sure the calculation happens whenever valoare is updated
		frm.set_value("rest_piata", cur_frm.doc.valoare - cur_frm.doc.discount);
	},
    discount: function(frm) {
            //This will make sure the calculation happens whenever discount is updated
		frm.set_value("rest_piata", cur_frm.doc.valoare - cur_frm.doc.discount);
	},
});
1 Like

Many Thanks!