This will update the “amount” field every time when any of the “qty”, “rate”, “area” field values are updated. If your field are child-tables use cdt, cdn as necessary in the code
// Set the amount as a product of area (width X height) , quantity and rate
frappe.ui.form.on("Quotation Item", 'qty', function(frm, cdt, cdn) {
var items = frm.doc.items
for (var i in items)
{
if(items[i].width && items[i].height){
var rate = flt(items[i].rate) * flt(items[i].width/100) * flt(items[i].height/100)
// will change the rate accordingly
frappe.model.set_value(cdt, cdn, "rate", rate)
}
}
});
Thank you the above code is working, Width and height are taken from item master and on changing the QTY in the quotation form the rate is changed accordingly and also the amount.