How can I make a filter non user removable in list view?

I have a Doctype that’s being filtered by specific criteria based on user role, How can I prevent the users from removing these filters?

Thanks in advance

Hi @JPaulMora,

If you want to hide the document type filter for two users, use1 and use2, you can do it by using the listview client script.

frappe.listview_settings['Your DocType'] = {
	refresh: function(listview) {
	    if (frappe.session.user == "user1@test.com" || frappe.session.user == "user2@test.com")
		$('.filter-selector').hide();
	}
};

Please set your doctype in the script.

Thank You!

can you pls share the code to filter list view based on user role? Also i am in hunt for how to filter based on below condition. Suppose a user is assigned to a warehouse(wh1). He should be able to see all the document which is issued/received in wh1. pls help

Hi @ErpnextRaja,

Then you can use

// if sales user then hide
frappe.user.has_role('Sales User') == 1

// If not sales user then hide
frappe.user.has_role('Sales User') == -1

You can set conditions according to the scenario.

Reference: How to make a button visible to User with specific role - #4 by NCP

I hope this helps.

Thank You!

Dear @NCP ,
Thanks for your reply. I understand this part. my question is
i am in hunt for how to filter based on below condition. Suppose a user is assigned to a warehouse(wh1). He should be able to see all the document which is issued/received in wh1. pls help
how to give sourcewarehouse=wh1 or destwarehouse=wh1 …

You should attempt to solve this using custom logic and server scripts. Developing this can be tricky.