Client Script to apply Filter on List View

Hi there,

is there any way to create a client script to apply a filter on a list view, when the list is loaded?

I got this but even there should be a result I always get a empty list:

frappe.listview_settings['Timesheet'] = {
    onload: function(listview) {
        listview.set_filter('workflow_state', 'Aproved');
    }
};

It would be really nice to get something like that working.
Thanks

Is your workflow state “aproved” or “approved”

Also try this

frappe.listview_settings['Timesheet'] = {
    onload : function(listview) {
        frappe.route_options = {
            "workflow_state": "Approved"
          };
        listview.refresh();
    }
};
2 Likes

@Yamen_Zakhour thank you very much that worked like a charm.

how could hidden the filter form the user to does not remove it

Reference: How to set a filter that cannot be modified by users in the List View? - #2 by NCP