I’m trying to calculate the total of a sum of five fields. The five fields are in a custom DocType child table.
Ideally the five fields would be select fields, where you can select a value from 1 - 5, but currently it’s just an Int field.
The DocType is called “Supplier Evaluation” and is a child table in the Supplier form. I tried to calculate the sum with the following script, but it somehow is not doing anyting.
frappe.ui.form.on("[Supplier Evaluation]", {
supplier_eval_score: function(frm, cdt, cdn) {
var d = locals[cdt][cdn];
var total = 0;
frappe.model.set_value(d.doctype, d.name, "[score]", d.supplier_evaluation_organization + d.supplier_evaluation_haccp + d.supplier_evaluation_pricing + d.supplier_evaluation_quality + d.supplier_evaluation_site + d.supplier_evaluation_employee);
frm.doc.supplier_evaluation_score.forEach(function(d) { total += d.score; });
}
});
At what point will the script fire? When I save the form? Or does it get fired with each change I make? And how to make this work?