ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

V11 my custom script for total budget not working

account

#1

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


#2

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


#3

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


#4

the field names are the same in v11
total_budget

budget_amount

doctype names are the same
Budget Account


#5

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


#6

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);
});


#7

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