How to add a column in child table which can show the total of other column?

@Anjalijangid frm.refresh_field(“items”)
Please dont copy this line write itself

frappe.ui.form.on("Quotation", {
validate: function(frm,cdt,cdn) {
let row = locals[cdt][cdn];
row.custom_total_cbm = (row.cbm * row.qty).toFixed(3);
frm.refresh_field("items");
}
})

please add this code in your client script

image

Copy and paste this script in direct client script box without any other place.

not working

what is the field type of cbm

I’m not sure why there are so many discussions on such a small topic, especially since this information is already available in “Frappe Forum.” I could have looked it up myself. There are 40+ discussions about a small client script, which is interesting :sweat_smile:

Please check your field name and set it in the script.

frappe.ui.form.on('Quotation', {
    validate: function(frm) {
        $.each(frm.doc.items || [], function(i, d) {
            frappe.model.set_value(d.doctype, d.name, 'custom_total_cbm', d.cbm * d.qty);
        });
    },
});

@Anjalijangid, Everyone here is new but they are also trying to learn, so you should be patient and try a little yourself :grinning:

haha @NCP :sweat_smile:

I try my best, after all my efforts when i could not make it up then i post my problem !

Thanks for your help but I don’t know why these codes are not working here :smiling_face_with_tear:

excuse me!

Still the total cbm is showing Zero only :cold_sweat: :sweat:

image

what is the field type for cbm??

Its Data

so use data field for cbm total as well because you are just fetching the data here

Please try the code below

frappe.ui.form.on(‘Quotation’, {
before_save: function(frm, cdt, cdn) {
let items = locals[cdt][cdn].items;
let custom_total_cbm = 0;
items.forEach(item => custom_total_cbm += item.custom_t);
frm.set_value(“custom_total_cbm”, custom_total_cbm);
}
});

frappe.ui.form.on(‘Quotation Item’, {
custom_cbm: function(frm, cdt, cdn) {
let items = locals[cdt][cdn];
let total_cbm = items.qty * items.custom_cbm;
locals[cdt][cdn].custom_t = total_cbm;
frm.refresh_field(‘items’)
},
qty: function(frm, cdt, cdn) {
let items = locals[cdt][cdn];
let total_cbm = items.qty * items.custom_cbm;
locals[cdt][cdn].custom_t = total_cbm;
frm.refresh_field(‘items’)
}
})

Worked !!
Thanks a lot !!
:smiley: :smiley:

For such queries Client script is used. Am happy you have the answers now