Hello,
I am trying to update the data read from the field of childtable present in other doctype in the field of childtable of current doctype. I am able to read the data from childtable but i cant find how to fill it in the autosuggestion options for the field in current doctype. Can anybody guide me through ?
details about the usecase -
SOURCEDOCTYPE = Vendors_List
SOURCECHILDTABLE = Item_Table
SOURCECHILDTABLE_FIELD = Item_Name
TARGETDOCTYPE = Order
TARGETDOCTYPE_FIELD = Link to SOURCEDOCTYPE
TARGETCHILDTABLE = Order_Table
TARGETCHILDTABLE_FIELD = Order_Item_Name
Selection in TARGETDOCTYPE ->TARGETDOCTYPE_FIELD is taken to access all the values from SOURCEDOCTYPE->SOURCECHILDTABLE->SOURCECHILDTABLE_FIELD and fill in the autosuggestion of the TARGETDOCTYPE ->TARGETCHILDTABLE->TARGETCHILDTABLE_FIELD.
PS : I am not looking for population the whole table but fill the autosuggestion and user will select the option for that field in the table.
I have tried 2 methods/options. opiton1 worked but didnt satisfy my requirement and second option gave me the error
Option1: JS side code
vendor_name: function(frm) {
console.log("Vendor Selected : " + frm.doc.vendor_name);
frappe.model.with_doc("Vendor List", frm.doc.vendor_name, function() {
var tabledata = frappe.model.get_doc("Vendor List", frm.doc.vendor_name);
$.each (tabledata.item_list, function(index, row) {
console.log("Index : " + index + " Item Name : " + row.item_name);
var d = frm.add_child("order_table");
d.item_name = row.item_name;
frm.refresh_field("order_table");
});
});
}
This is not i intend to do it but i want user to choose from autosuggestion…
Options2 : JS Code:
vendor_name: function(frm) {
console.log("Vendor Selected : " + frm.doc.vendor_name);
frm.fields_dict.order_table.grid.get_field('item_name').get_query = function() {
console.log("Before calling get_vendor_item from vendor_list.py");
return {
query: 'freshpoint_oms.freshpoint_oms.doctype.vendor_list.vendor_list.get_vendor_item',
filters: {
'parent': frm.doc.vendor_name
}
}
}
}
Python side:
def get_vendor_item(doctype, txt, searchfield, start, page_len, filters):
data = frappe.get_list(“Item List Table”, filters, [“item_name”])
return data
but i get error -
All i want to achieve is -
Would love to hear from the community,
Regards,
Praveen