Compute qty * net weight

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

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 :frowning:

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

not working either:

:frowning:

share your script screen short and also try after reload…

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

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

not working :frowning:

your script has issue. it’ll not work with this syntax.

what will I do? :frowning: