OR (not AND) filter conditions

I’m coding the filter conditions for Fixtures.

The following filter AND the 2 conditions, I want to OR them. How do I achieve that?

'filters':[['name','like','%@e-dc%'],['name','like','fn%.ln%@%']]

Hi @EugeneP,

Please try this.

Example:

// For In Condition
"filters": {
		"module": ["in", ["CRM","Selling"]]
	}

// For Equal Condition
"filters": {
		"module": ["=", "CRM"],
		"report_type": ["=", "Query Report"]
	}

// For Like Condition
"filters": {
		"module": ["like", "%CRM%"]
	}

Thank You!

Thanks @NCP

Even if I reconstruct the filter to your recommendation such as

{'doctype':'User', 'filters':{'name':['like','%e-dc%'],'name':['like','fn%.ln%@%']}}

it’s also not correct. It’s incorrect syntax since the key (‘name’) is repeated.

What I want is an ORed condition, something such as

‘name’:[‘like’,‘%e-dc%’] OR ‘name’:[‘like’,‘fn%.ln%@%’]

Hi @EugeneP,

In OR/Equal/In condition, you can set a name only once.

Yes, I’m aware of that, that’s why I use the array of arrays structure to define both conditions, of which both reference the ‘name’ docfield.

However, as a consequence they are ANDed together not ORed. My question is, is it at all possible to OR 2 conditions? Not necessarily using the structures we’ve explored here but some other way of achieving it?

I think it’s not possible.

Could you try


{'doctype':'User', 'filters':{'name':['like',['%e-dc%', 'fn%.ln%@%']]}}

Hi @Emily

Nope! SQL syntax error. But thanks anyhow.

frappe.get_all("Customer",filters={"name":"test"}, or_filters={"name":"test2"})

you can use or_filters instead of filters
Like

'or_filters':[['name','like','%@e-dc%'],['name','like','fn%.ln%@%']]
5 Likes

It worked @amadhaji.

Thanks.

Ah… well done @amadhaji