Try ERPNext Buy Support Partners Foundation

Add filter to field view

how to add or edit a filter to field view like below image

I try this code but not working

frappe.ui.form.on (“Stock Entry”, {
course_family: function(frm) {
cur_frm.set_query(“cost_center”, function() {
return {
“filters”: {
“is_group”: “0”
}
};
});
}
});

This link may help you: Set specific values in a field type Link

@Nahuel_Nso thanks for your response
but it’s not working

i got this error Cannot set property ‘get_query’ of undefined it try

frappe.ui.form.on(‘Stock Entry’, {
refresh(frm) {
cur_frm.fields_dict.cost_center.get_query = function(doc,cdt,cdn) {
return {
filters:[
[‘is_group’, ‘=’, “0”]
]
}
}
}
})

and

cur_frm.fields_dict.cost_center.get_query = function(doc,cdt,cdn) {
return {
filters:[
[‘is_group’, ‘=’, “0”]
]
}

Your field is inside a child table. This may be helpful: How to set filter query for dynamic link type

Solved

cur_frm.fields_dict[“items”].grid.get_field(“cost_center”).get_query = function(doc){
return {
filters:[
[‘is_group’, ‘=’,‘0’]
]
}
}