I am trying this code, it is getting added but the problem is that when I am entering data for the first time in the field, it is getting removed.
My code
frappe.ui.form.on("Sales Order Item", {
custom_0435: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_0536: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_0637: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_0738: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_0839: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_0940: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_1041: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_1142: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_1243: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_1344: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_1445: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_1546: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_1647: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_1748: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_0539: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_0640: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_0741: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_0842: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_0943: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_1044: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_1145: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_1246: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_1347: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_1448: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_1549: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_1650: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_0319: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_0420: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_0521: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_0622: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_0723: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_0824: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_0925: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_1026: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_1127: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_1228: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_1329: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_222555: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_3302: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_3403: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_3504: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_3605: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_3706: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_2507: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_2608: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_2709: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_2810: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_2911: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_3012: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
},
custom_3113: function(frm, cdt, cdn) {
calculateTotalQty(frm, cdt, cdn);
}
});
function calculateTotalQty(frm, cdt, cdn) {
var d = locals[cdt][cdn];
var totalQty =(d.custom_0435 || 0) + (d.custom_0536 || 0) + (d.custom_0637 || 0) + (d.custom_0738 || 0) + (d.custom_0839 || 0) + (d.custom_0940 || 0) + (d.custom_1041 || 0) + (d.custom_1142 || 0) + (d.custom_1243 || 0) +
(d.custom_1344 || 0) + (d.custom_1445 || 0) + (d.custom_1546 || 0) + (d.custom_1647 || 0) + (d.custom_1748 || 0) + (d.custom_0539 || 0) + (d.custom_0640 || 0) + (d.custom_0741 || 0) + (d.custom_0842 || 0) +
(d.custom_0943 || 0) + (d.custom_1044 || 0) + (d.custom_1145 || 0) + (d.custom_1246 || 0) + (d.custom_1347 || 0) + (d.custom_1448 || 0) + (d.custom_1549 || 0) + (d.custom_1650 || 0) + (d.custom_0319 || 0) +
(d.custom_0420 || 0) + (d.custom_0521 || 0) + (d.custom_0622 || 0) + (d.custom_0723 || 0) + (d.custom_0824 || 0) + (d.custom_0925 || 0) + (d.custom_1026 || 0) + (d.custom_1127 || 0) + (d.custom_1228 || 0) +
(d.custom_1329 || 0) + (d.custom_3302 || 0) + (d.custom_3403 || 0) + (d.custom_3504 || 0) + (d.custom_3605 || 0) + (d.custom_1650 || 0) + (d.custom_3706 || 0) + (d.custom_2507 || 0) + (d.custom_2608 || 0) +
(d.custom_2709 || 0) + (d.custom_2810 || 0) + (d.custom_2911 || 0) + (d.custom_3012 || 0) + (d.custom_3113 || 0) + (d.custom_222555 || 0);
frappe.model.set_value(cdt, cdn, 'qty', totalQty);
}
Thanks.