Geting a calculated value from child table into partent level field

Continuing the discussion from Sum fields amount From Child Table V7:

@Randy_Lowery, Can you please explain in more details what you had to do? Did you create a new child table and called it table?

Actually yes as in parent doctype a created a table field and call it table which is a reference to a doctype created as table, i named it Denominaciones so if you check my scrip below the table field gets referenced in the scrip in frm.doc.table.forEach(function(d) { total += d.valor; }); so you may ask why i called table, thats because i tried with another name and could not make it to work.

frappe.ui.form.on(“Denominaciones”, {
denominacion: function(frm, cdt, cdn) {
var d = locals[cdt][cdn];
var total = 0;
frappe.model.set_value(d.doctype, d.name, “valor”, d.denominacion * d.cantidad);
frm.doc.table.forEach(function(d) { total += d.valor; });
frm.set_value(‘balance_real’, total);
}
});

frappe.ui.form.on(“Denominaciones”, {
cantidad: function(frm, cdt, cdn) {
var d = locals[cdt][cdn];
var total = 0;
frappe.model.set_value(d.doctype, d.name, “valor”, d.denominacion * d.cantidad);
frm.doc.table.forEach(function(d) { total += d.valor; });
frm.set_value(‘balance_real’, total);
}
});