I have a list that I'm trying to query using ListData.svc. I am trying to pull back records within a date range and with a particular value from a Choice field checked. If I use Lists.asmx, I can build the CAML query to pull back the records I need, but I want to use ListData.svc for this solition. I am able to filter on columns whose values are stored in the list and I am using "$expand" to pull back the data for my Choice field, but I don't know how to structure the OData URI to filter based on the choice field.

I'm trying a query like this:

http://tssites/departments/appdev/_vti_bin/ListData.svc/TeamCalendar?$expand=Flags&$filter=Flags eq 'PTO'

The error I am getting back is:

Operator 'eq' incompatible with operand types 'System.Collections.Generic.IEnumerable`1[[Microsoft.SharePoint.Linq.DataServiceEntity, Microsoft.SharePoint.Linq, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c]]' and 'System.String' at position 6.

Thanks for your assistance.


It is not supported for multiselect fields (i.e. fields represented in the normal UI as check boxes). The following quote is for 2013 but the same rules apply for the ListData.svc. You can filter on the client side, though, depending on how you represent the data and the controls you use.

Queries for multi-value lookup fields and users

Because multi-value lookup fields are returned as a string of multiple values, there is no way to query for them (for example, the equivalent of an Includes element or NotIncludes element is not supported).



Choice fields are returned with a Value without the need for expansion:

Example: IP_WorkflowStatus = IP_WorkflowStatusValue

Here is an example of a query without using expansion:

$filter=IP_WorkflowStatusValue eq '2-Validated'

If you want to use expansion, then you need to use expanded field notation Relation/Field:

$filter=IP_WorkflowStatus/Value eq '2-Validated'&$expand=IP_WorkflowStatus
  • Thanks so much for your time, Chris. Neither of these work for my list. Is it because the Choice field uses checkboxes to allow for multiple selection? When I use your second example, I get the error mentioned in my question. When I use your first example (comparing against a value called FlagsValue), I get the error "No property 'FlagsValue' exists in type 'Microsoft.SharePoint.Linq.DataServiceEntity' at position 0." – Kevin Jun 14 '11 at 11:53
  • +1 for examples that moved the OP forward – Tom Resing Jul 7 '11 at 16:41

Retrieve choice field value in Rest API by attaching 'value' to the field name. for e.g. if your field name is Flags, use the term FlagsValue in the filter string. This works if the choice field is not a multi select field.

Your url should be like

http://tssites/departments/appdev/_vti_bin/ListData.svc/TeamCalendar?$expand=Flags&$filter=FlagsValue eq 'PTO'

There is another work around for this issue. Create a calculated column and add the Choice field as formula for it. Now use the calculated column for filtering.

For Multiselect Choice fields:

Follow the below steps.

  1. Add a new text column by name FlagsCSV
  2. Edit the editform of the list item and add a content webpart to it. Hook an html page to the content webpart. (Let the name of html page be content.html and upload this to libraries like SiteAssests)
  3. Edit the content.html and use jquery to add a change events to the options of Flags. Generate comma separated values of the multiple items selected Flag options and set it to the textBox of FlagsCSV.
  4. Save and close html page. Now every time you edit the list item, FlagsCSV will also gets updated.
  5. You may use the FlagsCSV field for your filtering later in your rest call.

Simple.. If you want to filter a choice field with name "color" just give like this:

$filter=colorValue eq 'blue'&$expand=color

Just append Value with column name. here colorValue

  • 2
    This will only work if the Choice field is set up as a Dropdown or as Radio Buttons. It will not work for those set up as Checkboxes. – ErinsMatthew Jun 17 '15 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.