I want to multiply qty and weight and set result is total weight,
to achieve this I am using following script but it does not work.
is it correct script?
frappe.ui.form.on("Gatepass Detail", {
qty: function(frm,cdt, cdn){
calculate_total(frm, cdt, cdn);
}
});
var calculate_total = function(frm, cdt, cdn) {
var child = locals[cdt][cdn];
frappe.model.set_value(cdt, cdn, "total-weight", child.qty * child.weight);
}
NCP
April 13, 2024, 7:36pm
2
Hi @Max_Fun ,
Max_Fun:
"total-weight"
Please check the fieldname because if there is no (-), only underscore (_) appears when creating the field. Go to the customize form and check the field name.
Reference:
Hi @NinYo ,
Please apply it.
frappe.ui.form.on("Appraisal Template - Performance", {
p_rating: function(frm,cdt,cdn) {
var d = locals[cdt][cdn];
frappe.model.set_value(cdt, cdn, 'p_score1', (d.p_rating + d.p_weight));
}
});
// Syntax
frappe.ui.form.on("Child Table Name", {
field_name_for_trigger_to_value_calculate: function(frm,cdt,cdn) {
var d = locals[cdt][cdn];
frappe.model.set_value(cdt, cdn, 'child_table_total_value', (d.child_table_value1 + d.c…
1 Like
frappe.ui.form.on("Gatepass Detail", {
quantity: function(frm, cdt, cdn) {
calculateTotalWeight(frm, cdt, cdn);
},
weight: function(frm, cdt, cdn) {
calculateTotalWeight(frm, cdt, cdn);
}
});
function calculateTotalWeight(frm, cdt, cdn) {
var d = locals[cdt][cdn];
var totalValue = d.quantity * d.weight;
frappe.model.set_value(cdt, cdn, 'total_weight', totalValue);
// Optionally refresh the field if necessary
// frm.refresh_field('total_weight');
}