frappe.ui.form.on("Appraisal", {
validate: function(frm){
this.calculate_total_work_plan();
},
calculate_total_work_plan: function(){
var total = 0;
var row_length = cur_frm.doc.plan_template.length || 0;
$.each(cur_frm.doc.plan_template || [], function(i, row) {
total += row.work_completed/row_length;
});
cur_frm.set_value("total_work_plan", total)
}
});
I created function calculate_total_work_plan which calculate total and assign to total_work_plan, this function will be called on event validate which happen before save, so you will see the total_work_plan amount after form saved.
If you want realtime update total_work_plan, you can call this function when work_completed value changed, cur_frm.trigger(“calculate_total_work_plan”). I haven’t tested it, you can try.
@magic-overflow, thanks for your code, i tried but no luck. this ‘Work_Completed’ data are from child table and its read only in parent table. Total_work_plan should change when Work_completed, but changes make from other page(other doctype), not from this page.