ERPNext Conference 2019* ERPNext.com Blog

Fetch batch number by filter according to item code and suggestion in select options


#1

Hello everyone,

i am trying to fetch batch number in select option when we enter the item code in Material Request Plan Item table, wrote custom script for Material Request Plan Item but didn’t help, can any one suggest me please. how to achieve that task.
my custom script is:

frappe.ui.form.on("Material Request Plan Item", "batch_no", function(frm, cdt, cdn) {
    var d = locals[cdt][cdn];
        frappe.db.get_value("Batch", {"item_code": d.item_code}, "batch_no", function(value) {
            //d.expiry_date = value.expiry_date;
            
            if(frm.doc.item_code == d.item_code)
  {
    set_field_options("batch_no", value.batch_no);
  }
            
        });
})

Thanks.