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%@%']]
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%@%’]
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%@%']]}}
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%@%']]
To help others, the full line of code for items is below.
obj_items = frappe.get_all(
"Item",
fields=["name", "item_name", "item_group", "description", "image", "stock_uom"],
filters={"disabled": 0},
or_filters={"item_name": ["like", f"%{search_text}%"],"description": ["like", f"%{search_text}%"]}
)