Hi all,
I need some assistance/guide here.
I have 2 doctypes
-
Target Doctype : Sales Order
1.1 Target child table :- Sales Order Item (items) -
Source Doctype : Item
2.1. Source child table : Item Customer Detail (customer_items)
My scenario/use case is :
in target child table (sales order item), there is 1 field name customer item description which should copy/fetched from source child table (Item Customer Detail) field name ref description. I’ve tried with numbers of tutorials listed in this forum but none of them able to fetch the data.
codes :
frappe.ui.form.on('Sales Order', {
onload: function (frm) {
if (frm.doc.item_code) {
frm.clear_table('items');
frappe.model.with_doc('Item', frm.doc.item_code, function() {
let source_doc = frappe.model.get_doc('Item', frm.doc.item_code);
$.each(source_doc.customer_items, function (index, source_row) {
var addChild = cur_frm.add_child("items");
addChild.ref_description = source_row.ref_description;
frm.refresh_field("items");
});
});
}
}
});
No error no anything. Nothing is prompted for me to trace back the error. Can anyone help me to point out where/why it is not working ? And where should I make the corrections ? let me know if you need any other information. I’ll attach on the next reply.