Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to filter w.r.t. multiple fields in oData using $filter?

What is the correct way to filter w.r.t. multiple fields when applying $filter command on more than one field/value pair from JavaScript?

like image 436
Bvrce Avatar asked Mar 07 '13 16:03

Bvrce


People also ask

How do I filter OData query?

You can use filter expressions in OData requests to filter and return only those results that match the expressions specified. You do this by adding the $filter system query option to the end of the OData request.

How use OData filter option?

You can find details on filter specification in the OData spec filter options section. Examples: All products with a Name equal to 'Milk': http://host/service/Products?$filter=Name eq 'Milk' All products with a Name not equal to 'Milk' : http://host/service/Products?$filter=Name ne 'Milk'

Is OData filter case sensitive?

OData API filter value which you are selecting for $FILTER parameter is always case sensitive.


2 Answers

It's very canonical.

http://192.168.75.8:5555/Konrad01/
  xrmservices/2011/OrganizationData.svc/
  LeadSet%28%29?$filter=
    Field1%20eq%20%27Value1%27%20and%20Field2%20eq%20%27Value2%27

EDIT:

More readable version.

http://Server:Port/Organization/XrmServices/2011/OrganizationData.svc/
  LeadSet()?$filter=Field1 eq 'Value1' and Field2 eq 'Value2'
like image 119
Konrad Viltersten Avatar answered Sep 20 '22 10:09

Konrad Viltersten


Put an and in between

Example:

http://YourServer.com/YourOrg/xrmservices/2011/OrganizationData.svc/ContactSet()?$filter=FirstName eq 'George' and LastName eq 'Washington'

like image 36
Daryl Avatar answered Sep 18 '22 10:09

Daryl