Listview not working well

Hi,
I am trying to filter by changing the _list.js file of a custom doctype. I wrote the following code

frappe.listview_settings['Documented Information'] = { add_fields: ["docstatus"], filters: [["docstatus","=","Draft"]] };

but nothing changes afrter both refresh from menu or by Ctr+Shift+R

What am I missing here?

docstatus is internal document status with values 0, 1 & 2.

filters: [["docstatus","=","0"]]

will get you Draft

Thank you @fahimalizain. Unfortunately didn’t work, I am still getting the same
Document Status !="Cancelled"

I also tried it without quotes

filters: [[“docstatus”,“=”,0]]

and also doesn’t work

The first time the Document Status was set as Cancelled, it was saved in the user_settings, so next time it is loaded over the default settings.

1 Like

Can you insert a console.log here and check whats happening ?

https://github.com/frappe/frappe/blob/develop/frappe/public/js/frappe/list/list_renderer.js#L52

The first array is the this.user_settings.filters and the second one the this.settings.filters

Delete the filter and refresh the page ?
Or set docstatus = Draft manually and on refresh it should be kept
For all the new users, it will be docstatus = Draft unless they visited the doctype earlier

What is the best way to clear the user_settings ? @netchampfaris

frappe.model.user_settings.remove(doctype, 'List')

1 Like

Thank you @fahimalizain and @netchampfaris for your responses but I’ve totally lost you.
It is supposed that filters could be set in _list.js file which I tried but that doesn’t seem to work. Is that a bug, is it a feature or what?
If that file isn’t enough to set some default filters, then which file could be edited and how? Through a custom script, a contribute to open source?

I thought that could be something simple

Basically, this filter is not valid.

And the list filters are applied for the first time, after that they are stored and fetched from the _user_settings, you can clear your user_settings from the database and the default filters will be loaded.