Hi guys,
I have a custom doctype and would like to get total of rows in child table displayed in parent table custom field. Below is my script. But its not working. Any advice is appreciated
frappe.ui.form.on(“Sales Report Details”, “sales”, function(frm, cdt, cdn) {
// code for calculate total and set on parent field.
total_sales = 0;
$.each(frm.doc.shop || [], function(i, d) {
total_sales += flt(d.sales);
});
frm.set_value(“sum_sales”, total_sales);
});
Child table: Sales Report Details
Parent table: Sales report
Custom field in Parent table is sum_sales