NCP
May 29, 2023, 9:05am
2
Hi @umarless ,
Please check the syntax.
DocType → Parent DocType
your_child_table_fieldname → Set your child table field name
d.amount → Set your amount field name which is in the child table
total_paid_amount → Set your parent total field name.
frappe.ui.form.on('DocType', {
validate: function(frm) {
var total_paid_amt = 0;
$.each(frm.doc.your_child_table_fieldname, function(i, d) {
amt += flt(d.amount);
});
frm.set_value("total_paid_amount", amt);
}
});
Please set the doctype, child table field name, and other field names accordingly.
Reference:
Hey @GhadaEbrahim ,
I think, you not proper understand.
Plesae match with field and doctype.
Supplier → Parent DocType
frm.doc.payment_details → Child Table field name in Parent DocType
d.collected_amount → Child table field name which you want to calculate in parent field.
debt_collected_amount → Parent Doctype field name.
frappe.ui.form.on('Supplier', {
validate: function(frm) {
var dca = 0;
$.each(frm.doc.payment_details, function(i, d) {
dca += flt(d.…
Hi @msiam ,
Please apply custom/client script.
frappe.ui.form.on('Sales Invoice', {
validate: function(frm) {
ttl_itms_dicnt = 0;
$.each(frm.doc.items, function(i, d) {
ttl_itms_dicnt += flt(d.discount_amount);
});
frm.doc.total_items_discount = ttl_itms_dicnt;
}
});
Please check your field name and set it according.
Then reload and check it.
Thank You!
I hope this helps.
Thank You!
1 Like