Hi All,
I refer this instruction " HOW TO: Fetch Child Tables ", but still doesnt work. Here is my case, I want to copy Length UOM
s row value to another child table Length UOM B.
Here is my code,
//for js side code
{
frappe.ui.form.on('Customer item test', {
refresh: function(frm) {
}
});
frappe.ui.form.on("Customer item test","refer_item_no",function(frm){
console.log("refer change");
if(cur_frm.doc.refer_item_no){
console.log("refer_item_no is true");
return frappe.call({
method: "get_child_table",
args:{
"doc":cur_frm.doc.refer_item_no
},
callback: function(r) {
if(cur_frm.doc.item_length_uom){
cur_frm.doc.item_length_uom = ""
refresh_field("item_length_uom")
console.log("item_length_uom refresh");
}
$.each(r.message, function(i, d) {
var row = frappe.model.add_child(cur_frm.doc, "Length UOM B", "item_length_uom");
row.item_size_name = d.item_size_name;
row.length = d.length;
row.width = d.width;
row.height = d.height;
row.lwh_unit = d.lwh_unit;
row.amount = d.amount;
refresh_field("item_length_uom");
console.log("item_length_uom refresh 2");
});
}
})
}
})
// for server side code
class Customeritemtest(Document):
pass
#Fetch table customization below
def get_child_table(doc):
frappe.msgprint("function get_child_table excuted")
doc_a = frappe.get_doc("Item",doc)
if(doc_a):
frappe.msgprint("Doctype Item got!")
else:
frappe.msgprint("Doctype Item wasn't got!")
list1 = []
field_test = doc_a.get("item_length_uom")
if(field_test):
frappe.msgprint("item_length_uom got!")
for t in doc_a.get("item_length_uom"):
list1.append({
'item_size_name':t.item_size_name,
'length':t.length,
'width':t.width,
'height':t.height,
'lwh_unit':t.lwh_unit,
'amount':t.amount
})
frappe.msgprint(list1)
return list1
I get my print console log “console.log(“refer_item_no is true”);”, but when I put the refer_item_code, it will show me "The resource you are looking for is not available
", is there are any missing on my steps?
Thanks your kindly help.