Hi all,
I’m trying to update some custom fields in Project form whenever a Task with a set Task type is saved. But something seems to be wrong. Here’s the client script I’m using
frappe.ui.form.on("Task", {
save: function(frm) {
if (frm.doc.project) {
frappe.call({
method: "frappe.client.get_list",
args: {
doctype: "Task",
filters: [
["Task", "project", "=", frm.doc.project],
["Task", "type", "=", "कामाचे मोजमाप"]
],
fields: ["total_in_cubic_mts", "water_storage"]
},
callback: function(r) {
if (r.message) {
var project_total = 0.0;
var water_storage_total = 0.0;
$.each(r.message, function(i, row) {
project_total += flt(row.total_in_cubic_mts);
water_storage_total += flt(row.water_storage);
});
frappe.model.set_value("Project", frm.doc.project, "project_total", project_total);
frappe.model.set_value("Project", frm.doc.project, "total_water_storage", water_storage_total);
frappe.model.save("Project", frm.doc.project);
}
}
});
}
}
});