Calculate field in item

i have in attribute ( Length and Width)
and in item i have ( Area)

how i can make Area calculate by auto ( Length*Width)

One way to accomplish it is to create a new server side JS custom script and write something like this (use the awesome bar and search for “Custom Script”):

frappe.ui.form.on('Item', {
validate: function(frm, cdt, cdn) {
    // make calculation on the fields
    var length = flt(frm.doc.length);
    var width = flt(frm.doc.width);
    var area = length * width;
    frm.set_value('area', area);


please adjust the field names accordingly.

sorry this photo

not working

Did you save the doc? Should be updated after save.
The code is executed on “Validate”.

yes i saved
can i send to you link for system ?

sure can

hold on, I just realized, you are using variant attributes. Please make sure the field names are really are correct. I don’t use variants for myself so I’m not sure how to address the fields in the script.

just checked with a dummy item.
Indeed the variant attributes are saved in a table. So you’ll need to get the value from the attributes table not simply from doc variables.
Check how to do it and adjust the script.

what do you mean variant attributes