I want to filter item_code in Delivery note based on field brand_name

I want to filter item_code in Delivery note based on field brand_name
(both item_code & brand_name are in child table Delivery Note Item (field name items))

I had created extra field ‘i1’ type link field and options Item (same as item_code)

  1.   My following code works pefectly for 'i1' , but not for 'item_code'. 
    

cur_frm.fields_dict[‘items’].grid.get_field(‘i1’).get_query = function(doc) {
return {

		filters: {
			 "brand": "brand1"
			
		}
	}
}
  1. and how to refer dynamic filter field
    ‘brand_name’ instead of fixed value “brand1”.

did you try doc.brand_name ?

Not working doc.brand_name

pls also give help why filter work on ‘i1’ but not on ‘item_code’

frappe.ui.form.on(“Delivery Note”, “onload”, function(frm) {
frm.fields_dict.items.grid.get_field(‘i1’).get_query =
function() {
return {
filters: {
“brand”: cur_frm.get_field(“items”).grid.grid_rows[0].doc.brand_name
}
}
}
});

----- above code solved my requrement of 'brand_name ’
But it works on ‘i1’ . I want on ‘item_code’

1 Like