I’m using “%” on my “LIKE” filters but seems it only works if it placed in the end. for example:
{{host}}api/resource/Fees?fields=[“*”]&filters=[[“name”,“LIKE”,“EDU-FEE-2023%”]]
it will return some results…
But this one:
{{host}}api/resource/Fees?fields=[“*”]&filters=[[“name”,“LIKE”,“%2023-00002”]]
it will return empty result
Why it happens? Am I using it wrong?
Masky
January 17, 2024, 10:40am
2
In SQL and Frappe queries, using % at the beginning of the search pattern is not always supported, and it might not work as expected. The % wildcard is typically used for matching at the end or both ends of the pattern.
If you want to perform a substring match for records that contain “2023-00002” anywhere in the name, you can use % at both ends
you mean something like this:
[[“name”,“LIKE”,“%2023-000%”]]
??
because it also not working. nothing return
/api/resource/Item?filters=[["Item","item_code","like","100363%"]]
I can confirm that this is working.
Make sure you DO NOT have a forward slash between the DocType and the question mark: Item/?filters
- this will not work.
Yes, this one will work, but it will return just all item that the item_code started with “100363…”
what I want is all item that contains “…100363…”
avc
July 22, 2024, 5:02pm
6
Hi @oscarutomo :
You should url-encode ‘%’ character … this way:
(http://yoursite.com/api/resource/Opportunity?fields=["name","status","party_name","transaction_date"]&filters=[["Opportunity","party_name","like","%25Palmer%25"])
(%25
represents ‘%’ character)
It will show all opportunities where party_name includes ‘Palmer’ on any position.
Hope this helps.
3 Likes