Search code examples
javascriptrestsharepoint-2010client-side

REST Query based on Expanded columns in multi choice fields (Listdata.svc)


I have a SP2010 client side app making REST calls. I have a large list that I would like to make a filtered query using the value of a none or many choice field called 'displays'. I have no access to add to server side code on this one.

When I 'expand' the query I can access the value of the choice like so

myDataVar.d.results[0].Displays.results[0].Value

Because dragging 1000 rows to the client to show 20 is cruel and unusual network punishment I need to filter d.results on .Displays.results[0].Value.

I have tried this:

[site]/_vti_bin/Listdata.svc/MasterDataList?$filter=Displays/Value eq 'Wide'

I am rewarded with the error message

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

Per another thread I have tried

/_vti_bin/Listdata.svc/MasterDataList?$filter=DisplaysValue eq 'Wide'&$expand=Displays

error:

No property 'DisplaysValue' exists in type 'Microsoft.SharePoint.Linq.DataServiceEntity' at position 0.

Testing for 'Displays' without the 'Value' suffix the error 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 9.


My stuck back in 2010 again thanks in advance.


Solution

  • The methods you are attempting only work with choice columns that are NOT multi-select. Unfortunately, multi-select choice columns are not supported by the REST interface. Same holds true for SharePoint 2013 apparently.

    FWIW, I ran into this same issue when trying to do the same thing from an Angular JS app within SharePoint. I ended up creating my own implementation of a multi-value choice field, which then stores the resulting data in JSON format inside of a multi-line text column in SharePoint. This then allowed me to query that field using REST with no problems.