Hello,
Try following script in the thread on how to calculation field. But script doesn’t work.
please see below
frappe.ui.form.on(“Sales Invoice Item”, “totalw”, function(frm, doctype, name) {
var row = locals[doctype][name];
row.totalw = row.qty * row.cbm;
refresh_field(“items”);
});
totalw = target field
cbm: custom field - from item net weight
Please help. Thanks
ossphinc:
frappe.ui.form.on(“Sales Invoice Item”, “totalw”, function(frm, doctype, name) {
The function should be triggered on qty
and cbm
. Hence it should look like frappe.ui.form.on(“Sales Invoice Item”, “cbm”, function(frm, doctype, name) {
hello,
so the script should be like this:
frappe.ui.form.on(“Sales Invoice Item”, “cbm”, function(frm, doctype, name) {
var row = locals[doctype][name];
row.totalw = row.qty * row.cbm;
refresh_field(“items”);
});
?
still not working
any error showing in console?
which doctype did you choose in custom script Sales Invoice or Sales Invoice Item??
yes, no error in error log.
i put this under sales invoice item
put it in Sales Invoice.it will working
1 Like
share your script screen short and also try after reload…
adnan
July 18, 2018, 6:07am
11
the main mistake every new user is doing is.
you must attaching this script with “Sales Invoice Item” in custom script list.
attach it with “Sales Invoice” and it’ll work
here,
Also tried loading this in Sales Invoice but error
use this script
frappe.ui.form.on("Sales Invoice Item", "cbm", function(frm, doctype, name) {
var row = locals[doctype][name];
row.totalw = row.qty * row.cbm;
refresh_field(“items”);
});
adnan
July 18, 2018, 6:10am
14
yes here is the is issue.
in doctype select Sales invoice only
1 Like
yes you should change" Sales Invoice Item" doctype to “Sales Invoice”
if i put the script to sales invoice doctype
my sales invoice is not appearing
please change also this line of code from refresh_field(“items”) to
refresh_field("items");
adnan
July 18, 2018, 6:26am
20
your script has issue. it’ll not work with this syntax.