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

In my quotation child table a have a column of CBM, I want another column named as Total CBM (CBM X quantity).

Just like there a column of rate and amount.

Kindly assist!

@Anjalijangid
go to customization of quotation item table and add new field total bdm
frappe.ui.form.on(‘Quotation Item’, { // Replace ‘Quotation Item’ with your child table Doctype name
cbm: function (frm, cdt, cdn) {
let row = locals[cdt][cdn];
row.total_cbm = row.cbm * row.qty; // Calculate Total CBM
frm.refresh_field(“items”); // Replace ‘items’ with the name of your child table field
},
qty: function (frm, cdt, cdn) {
let row = locals[cdt][cdn];
row.total_cbm = row.cbm * row.qty; // Calculate Total CBM
frm.refresh_field(“items”); // Replace ‘items’ with the name of your child table field
}
});
create client script

1 Like

Thanks for the reply @Jeel
But i dont have any knowledge of code.
Is there any other way?

Like I have seen, for total they have used Float field-type here, is this information useful ?

@Anjalijangid Please First Add the custom field on your child table then add the client script in quotation doctype and the write this code and test your testcase

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

1 Like

What field type shall i select for Total CBM custom field?

This is want i want -

@Anjalijangid Fieldtype should ne Currency

Not working -

@Anjalijangid try this code frappe.ui.form.on(‘Quotation’, {
validate: function(frm) {
let row = locals[cdt][cdn];
row.total_cbm = row.cbm * row.qty;
frm.refresh_field(“items”);
}
})

image

@Anjalijangid remove default code and just paste my code

image

@Anjalijangid try this code frappe.ui.form.on(‘Quotation’, {
validate: function(frm,cdt,cdn) {
let row = locals[cdt][cdn];
row.total_cbm = row.cbm * row.qty;
frm.refresh_field(“items”);
}
})

image

@Anjalijangid remove quote with “” in frm.refresh_field("items’')

Now the codes are correct but its not working

its showing zero instead of 10X0.464

image

@Anjalijangid when your form is saved its working


Its saved, but not working
Also, CBM is not in currency format its just in numbers

@Anjalijangid change to total cbm to fieldtype float

you are making changes in the cbm field and in refresh field you have written items…??


:sweat_smile: :sweat_smile: