I'm trying to use SharePoint 2010 ListData.svc with jqgrid control. It works fine, but when I try to use orderby with lookup field, I get an exception:

-An error occurred while processing this request.-Value cannot be null. Parameter name: targetSystem.ArgumentNullException at Microsoft.SharePoint.Linq.DataServiceUtil.GetValue(Object target, ResourceProperty resourceProperty) at lambda_method(ExecutionScope , DataServiceEntity ) at System.Linq.Enumerable.<>c__DisplayClass123.<CombineSelectors>b__11(TSource x) at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Data.Services.Providers.BasicExpandProvider.ExpandedEnumerator1.MoveNext() at System.Data.Services.DataService1.SerializeResponseBody(RequestDescription description, IDataService dataService) at System.Data.Services.DataService1.HandleNonBatchRequest(RequestDescription description) at System.Data.Services.DataService1.HandleRequest()

This Exception throws only if target list have items with empty lookup field. Is this correct?

For example - my url: http://{servName}/_vti_bin/listdata.svc/{ListName}()?$expand=LkTest&$select=Title,LkTest&$orderby=LkTest/Title

1 Answer 1


Most probably this error occurs due to orderby operator, in particular this error is encountered when lookup value is null(empty) and hence ordering by projected field could not be applied:

$orderby=LookupField/ProjectedFieldName  //<- LookupField is null

The solution would to apply the filter that excludes list items with null lookup values, for example:

$filter=LookupField ne null

Complete example:

/_vti_bin/listdata.svc/ListName?$expand=LookupField&$select=Title,LookupField&$filter=LookupField ne null&$orderby=LookupField/FieldName 
  • I also thought about the filter, but it will not be entirely correct to exclude from list some items just because they lookup field is not filled. At least a standard interface does not do this. Are there any other ways to solve this problem? Mar 11, 2015 at 10:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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