Need to Filter Customers By Company

i need a java script that can filter customers by company that can make me see only the customers of this company

frm.set_query(“customer”, function() {
return {
filters: {
‘company’: frm.doc.company
}
};
});

it doesn’t work i hAVE ALSO ERRORS

frappe.ui.form.on(“Sales Invoice”,{
company: function(frm){
frm.set_query(‘project’, function() {
return {
filters: {
‘company’: frm.doc.company
}
};
});
}
});

Custom script above works.
I’ve tried to filter project by company as the customer don’t link to any companies (my test site). You just change project to customer

Edit:
If you want to set event to on refresh

frappe.ui.form.on(“Sales Invoice”,{
refresh: function(frm){
frm.set_query(‘customer’, function() {
return {
filters: {
‘company’: frm.doc.company
}
};
});
}
});

1 Like

Hi @Roger @magic-overflow, maybe you managed to filter the field, I’m trying to do the same filter and it does not work