Skip to Content
0

Model filter is missing single quotes to the substring parameter

Nov 09, 2017 at 01:42 PM

53

avatar image
Former Member

Hi,

Could anyone please help me understanding and resolving the below issue.

I have create the below filter to get suggestions

var value = oEvent.getParameter("suggestValue");

var filters = [];

if (value) {

filters = [ new sap.ui.model.Filter([

new sap.ui.model.Filter("Equipment",sap.ui.model.FilterOperator.Contains,value) ]) ];

}

the above code returns the following request

Equipment%20asc&$filter=(substringof(701744000,Equipment)) ... here i am missing the single quotes

But this will work if I explicitly pass single quotes in the above code like this

new sap.ui.model.Filter("Equipment",sap.ui.model.FilterOperator.Contains,"'"+value+"'") ]) ];

}

returns the below request

Equipment%20asc&$filter=(substringof(%27701744000%27,Equipment))

Now here is my total confusion with sap.ui.model.Filter...

there is a situation where model filter worked for me without passing explicit single quotes

the code looks like below

var sQuery = oEvent.getParameter("query");

new Filter("EquipmentNumber", FilterOperator.Contains, sQuery);

the request looks like below

EquipmentSet?$skip=0&$top=5&$orderby=EquipmentNumber%20asc&$filter=substringof(%27701744000%27,EquipmentNumber)

Could anyone please help me in understanding it.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Jun Wu Nov 09, 2017 at 03:18 PM
0

value=""+value;

how about doing that before passing to the filter?

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thanks for the response.

But why do we need to pass it before and how it makes the difference.

As i mentioned this code even works without passing single quotes

var sQuery = oEvent.getParameter("query");

new Filter("EquipmentNumber", FilterOperator.Contains, sQuery);

And one more strange thing today the below code works even without passing single quotes but not on the day i posted the question but please let me know in understanding the difference

new sap.ui.model.Filter("Equipment",sap.ui.model.FilterOperator.Contains,value) ]) ];

0