Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Querying choice field in Sharepoint using rest

I got a list in Sharepoint 2010 with a choice column. The choices are checkboxes.

How do I query the choice column using the rest api?

I've tried using

http://sp2010/_vti_bin/listdata.svc/mylist?$filter=myChoicesColumn/xxx eq something 

and then I get

No property 'xxx' exists in type 'System.Collections.Generic.IEnumerable`1[[Microsoft.SharePoint.Linq.DataServiceEntity, Microsoft.SharePoint.Linq, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]]' at position 6.

What property should I use?

like image 885
Ivar Avatar asked Mar 21 '11 14:03

Ivar


1 Answers

None of these answers will work for SP fields that are of type multiselect (i.e. fields represented as checkboxes).

If you try the following filter on a multiselect choice field called "Grouping" like this:

$filter=Grouping/Value eq 'My Value'

You will get the error:

{
    "error": {
        "code": "",
        "message": {
            "lang": "en-US",
            "value": "No property 'Value' exists in type 'System.Collections.Generic.IEnumerable`1[[Microsoft.SharePoint.Linq.DataServiceEntity, Microsoft.SharePoint.Linq, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c]]' at position 9."
        }
    }
}
}

Maybe Value isn't required? You still get an error. In SP 2013 the MSDN documentation states that querying a multiselect choice is not possible. So I can only assume that the same is true for the 2010 REST API, which is hardly documented at all.

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

like image 184
Robert Kaucher Avatar answered Oct 16 '22 21:10

Robert Kaucher