Filters with OR (any) instead of AND (all)

Most of the various document queries in the system require a ‘filters’ array. It looks like the stock behavior is that the filters are chained with AND. Is it possible to chain them with OR so that records matching ANY of the conditions will match instead of only records matching ALL of the conditions?

Example usage would be javascript listview_settings filter. I’d like to show all documents that match any of the filter conditions.

1 Like

Yes, this exists. Just use or_filters exactly as you would filters:

frappe.db.get_list("Employee", { 
    or_filters: [ ['first_name', '=', 'Alice'], ['first_name', '=', 'Bob'] ]
}).then(r => console.log(r))

Thanks, Peter G.

I see that or_filters is available for the db methods, but not for listview_settings. :frowning:

I tried or_filters with listview_settings and it doesn’t work.

I think that’s right. I don’t believe there’s a way out of the box to use or filters on the list view. Some things you can achieve with the in operator, but for anything more complicated you’d have to customize I think.

Thanks peterg!