Set query not working on Material request

Hai,

The following client script is not working on material request

frappe.ui.form.on(“Material Request”, “onload”, function(frm) {
console.log(“Script is running.”);
frm.fields_dict[‘items’].grid.get_field(‘item_code’).get_query = function(doc, cdt, cdn) {
var child = locals[cdt][cdn];
console.log(child);
return {
filters: [
[‘item_group’, ‘=’, ‘Services’]
]
};
};
});

but when i try similar code in Purchase order or quotation it is filtering the group

1 Like

@KAMAL_DAS ,
I am on V14. Please try this script.

frappe.ui.form.on("Material Request", 
   cur_frm.cscript.onload = function(frm) {
	cur_frm.set_query("item_code", "items", function() {
		return {
			filters: {"item_group": "ABC"}
		}
})});

Thnks.

Dear @Suresh_Thakor It is working. Thanks…