cancel
Showing results for 
Search instead for 
Did you mean: 

Case insensitive search in UI5 oData filter

ibibhu
Product and Topic Expert
Product and Topic Expert

Dear Community,

I am trying to do a case-insensitive search by passing in the following way :-

oData Filter :

$filter= substringof( "query" , tolower(Vendor_name))

In ui5 i tried to build the filter in the following way :-

new Filter("tolower(Vendor_name)", FilterOperator.Contains, "query" )

Generated oData Query :

$filter= substringof( query, tolower(Vendor_name))

// without the double quotes and which results in the error Invalid filter expression

I tried to append single quotes :-

new Filter("tolower(Vendor_name)" ,  FilterOperator.Contains,  " ' " + "query"+ " ' " )
Generated oData Query :
$filter= substringof( 'query' , tolower(Vendor_name))

// with the single quotes and search is working fine but with console Assertion error

Error: assert-dbg.js:34 
Assertion failed: PropertyType for property tolower(Document_no) of EntityType Record not found!


Is this a bug , or this is not the right way to use it ?

What is the best way to do in case of case insensitive search in UI5 ?

Thanks and regards,
Bibhu

View Entire Topic
jordanvde
Explorer

https://ui5.sap.com/1.78.0/#/api/sap.ui.model.Filter

The filter has a 'caseSensitive' parameter, maybe this can help you?

with 'caseSensitive: true' the query would look like this:
?$filter=substringof(%27vinet%27,CustomerID)

if we set it to false:
?$filter=substringof(%27VINET%27,toupper(CustomerID))

				var oFilter = new Filter({
					path: "CustomerID",
					operator: FilterOperator.Contains,
					value1: sQuery,
					caseSensitive: false
				});
ibibhu
Product and Topic Expert
Product and Topic Expert

Thanks @jordanvde

Always loved to see how SAP community responds faster than any channel 🙂