Good morning everyone,
Firstly i want to say i just read the following topic HOW TO: Fetch Child Tables - #10 by adam26d, but since i’m new to this practice i don’t know how to set the fields correctly.
Now i’ll explain my use case: Simply i’d like to add in the Production Order, once i select the Item to Manufacture, the correspondent BOM Item (first level only, not exploded). So i created a custom field table type (“bom_item”) which is linked to child doctype “BOM Item 2” (i read somewhere that the child table i want to fetch the values to must be different from the child table from where i get them).
I used the following code, where:
“production_item” is the field used as trigger,
“bom_item” is the custom field used as table (where i want to fetch the BOM item of the item i select in production_item),
“bom_no” is the default field (in Production Order DocType) where appear the BOM related to the item i choose to manufacture,
“items” is the default field (in BOM DocType) which contains the BOM Item child table,
“code”, “name1”, “uom” and “qty” are the fields inside the BOM Item 2 child table.
frappe.ui.form.on("Production Order", "production_item", function(frm) {
frappe.model.with_doc("bom_no", frm.doc.production_item, function() {
var tabletransfer= frappe.model.get_doc("bom_no", frm.doc.production_item)
$.each(qmtable.items, function(index, row){
d = frm.add_child("BOM Item 2");
d.item_code = row.code;
d.item_name = row.name1;
d.stock_uom = row.uom;
d.qty = row.qty;
cur_frm.refresh_field("BOM Item 2");
})
});
});
Hope i explained the case clearly and that someone can help me.