Hi , I have a problem with my script, what it does is sum “costos” column in the child table “costo” but it shows an error message about the syntax, but the syntax of the script is correct!
frappe.ui.form.on(“TestTable”, {
ctotal:function(frm, cdt, cdn){
var d = locals[cdt][cdn];
var total = 0;
frm.doc.costo.forEach(function(d) { total += d.ctotal; });
frm.set_value(“costos”, total);
refresh_field(“costos”);
},
costo_remove:function(frm, cdt, cdn){
var d = locals[cdt][cdn];
var total = 0;
frm.doc.costo.forEach(function(d) { total += d.ctotal; });
frm.set_value(“costos”, total);
refresh_field(“costos”);
}
});
i made a little changes and works perfectly! thanks
The final script for future consultations.
TableChild = Doctype of the child table
costo = the column that will be summed
table_2 = the table field on the parent doctype
total_01 = the float field where the total will be displayed
frappe.ui.form.on(“TableChild”, {
costo:function(frm, cdt, cdn){
var d= locals[cdt][cdn];
var total = 0;
cur_frm.doc.table_2.forEach(function(d) { total += d.costo; });
frm.set_value(“total_01”, total);
refresh_field(“total_01”);
},
table_2_remove:function(frm, cdt, cdn){
var d= locals[cdt][cdn];
var total = 0;
cur_frm.doc.table_2.forEach(function(d) { total += d.costo; });
frm.set_value(“total_01”, total);
refresh_field(“total_01”);
}
});