Hi,
If could I have some help please,
In Doctype “Project”, I have created a custom field ‘total_committed_amount’, I need to fetch the total value from field “amount” in Doctype “Purchase Order Item”,
I have seen this example working with child tables but it doesn’t include the calculation,
Any help would be very welcome,
frappe.ui.form.on('Project', {
Purchase_Order: function (frm) {
if (frm.doc.Purchase_Order) {
frm.clear_table('total_committed_amount');
frappe.model.with_doc('Purchase_Order_Item', frm.doc.Purchase_Order, function () {
let source_doc = frappe.model.get_doc('Purchase_Order_Item', frm.doc.Purchase_Order);
$.each(source_doc.Project, function (index, source_row) {
frm.add_child('total_committed_amount').Amount = source_row.Amount ; // this table has only one column. You might want to fill more columns.
frm.refresh_field('total_committed_amount');
});
});
}
},
});