Filter in Listview

Hey there,

i want to apply filter to a Listview of a doctype with a client script. I tried many approaches, but had no success. I thought this would be simple with a few lines of code, but I’m going trough hell with this task.

Can anyone help me?

Great Weekend to all of you!

Hi @Viktor_Kuhn,

Please apply the listview client script for that.

frappe.listview_settings['Sales Order'] = {
	onload: function(listview) {
		frappe.route_options = {
			"status": ["!=", "Completed"]
		};
	}
};

Here I applied the filter using the listview client script for Sales Orders and only showed the non-completed orders when you reload the sales order.

Output:

I hope this helps.

Thank You!

1 Like

@NCP , how to set filter for the below… I am searching …but couldn’t find any refrence.
my condition is status not completed or status is Draft… How to give OR here…

How do you mean exactly? In list view, you can see the filters as displayed in the image above. If you mean setting the filter with the client script, implementing it via the doctype “client script” would be your way to go.

Hi @ErpnextRaja,

That time you can use ‘in’ condition.

Please check it.

frappe.listview_settings['Sales Order'] = {
	onload: function(listview) {
		frappe.route_options = {
			"status": ["in", ["Draft", "To Deliver and Bill", "To Bill", "To Deliver"]]
		};
	}
};

I hope this helps.

Thank You!

1 Like

Dear @mrPauwHaan , @NCP ,
Thanks for your reply. My use case is, For example take Stock Entry doctype. In list of that doctype I want to filter as follows.

  1. suppose the user is store keeper for WH-A.
  2. So, in his list view he should only see the transaction which is having from_warehouse is WH-A or to_warehouse is WH-A.
    This is my question…

Hi @ErpnextRaja,

I don’t think, ‘or’ condition worked in the listview.

@ncp, Thanks for your reply.