Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]]' and 'System.String' at position 6.

Thanks for your assistance.

share|improve this question
    
A similar question was posted on StackOverflow recently. At the moment the answers don't add anything to this thread, but you might want to follow it: stackoverflow.com/questions/5379371/… –  Tom Resing Jul 7 '11 at 16:40

2 Answers 2

up vote 2 down vote accepted

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).

http://msdn.microsoft.com/en-us/library/fp142385(v=office.15).aspx

share|improve this answer

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

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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