cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Model filter is missing single quotes to the substring parameter

rajanig9
Explorer
0 Kudos
1,392

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.

View Entire Topic
EE8
Newcomer
0 Kudos

I am a bit late to the party but this exact problem happened to me before. It looks like a bug in the Filter constructor you are using: 

new sap.ui.model.Filter(sPath, sOperator, vValue1, vValue2);


Try using the one with an object as a parameter:

new Filter({
      path: "Price",
      operator: FilterOperator.BT,
      value1: 11.0,
      value2: 23.0
    });