V11 my custom script for total budget not working

Continuing the discussion from How can I calculate total budget allocated:
Hello,
I created a custom script in v10 to calculate total budget

frappe.ui.form.on(“Budget Account”, “budget_amount”, function(frm, cdt, cdn) {
// code for calculate total and set on parent field.
total_budget = 0;
$.each(frm.doc.accounts || , function(i, d) {
total_budget += flt(d.budget_amount);
});
frm.set_value(“total_budget”,total_budget);
});

Here is how it worked,

In v11 it is not working

What has changed? what modifications can I make to get my script to work in v11?

Thanks

Edit:
Installed Apps
ERPNext: v11.1.3 (master)
Frappe Framework: v11.1.3 (master)

The script is ok, can you test fields name to check if thy are same for fields and doctype name in the new version !

the field names are the same in v11
total_budget

budget_amount

doctype names are the same
Budget Account

help anyone? still haven’t found a solution
Now running
ERPNext: v11.1.4 (master)
Frappe Framework: v11.1.4 (master)

Hello, try like this:

frappe.ui.form.on(“Budget Account”, “budget_amount”, function(frm, cdt, cdn) {
// code for calculate total and set on parent field.
var total_budget = 0;
$.each(frm.doc.accounts || [], function(i, d) {
total_budget += flt(d.budget_amount);
});
frm.set_value(“total_budget”,total_budget);
});

1 Like

Thank you so much. It worked :grin::grin::grin: