I am trying to retrieve all Customer Contracts which Customer Master has Procurement Relevant = True

I used CSOM to communicate with SharePoint 2010 to retrieve list items and used CAML query to filter and join lists .

List list = web.Lists.GetByTitle("Customer Contracts");
var itemColl = await Task.Run<ListItemCollection>(() =>
                    CamlQuery query =//CAMEL query showed below 

                    ListItemCollection coll = list.GetItems(query);
                    // Execute the query to the server
                    return coll;

It raised the following exception when query executed

Exception : ( Microsoft.SharePoint.Client.ServerException was unhandled by user code HResult=-2146233088 Message=Value does not fall within the expected range. Source=Microsoft.SharePoint.Client.Runtime ServerErrorCode=-2147024809 ServerErrorTypeName=System.ArgumentException )

Check the following CAML query :

<View Scope="RecursiveAll">
                <FieldRef Name="CustomerProcurementRelevant" />
                <Value Type="String">True</Value>
        <Join Type="INNER" ListAlias="Customer Master">
            <Eq><FieldRef Name="Customer_x0020_ID" RefType="Id" />
                <FieldRef List="Customer Master" Name="ID" />
        <Field Name="CustomerProcurmentRelevant" Type="Lookup" List="Customer Master" ShowField="Procurement_x0020_Relevant" />
        <FieldRef Name="Modified" /><FieldRef Name="Customer_x0020_ID" /><FieldRef Name="Title" /><FieldRef Name="ES_x0020_Service_x0020_Segment" />
        <FieldRef Name="ADE_x002f_ADM" /><FieldRef Name="Account_x0020_Controlling" /><FieldRef Name="Contract_x0020_terminated" /><FieldRef Name="Country" />
        <FieldRef Name="CustomerProcurmentRelevant" />

1 Answer 1


You should pass a SPQuery object to the GetItems method. In the query attribute you have to put just the <Query> tag. Use:

SPQUery query = new SPQuery();
query.Query = "" //your <Query>...</Query> tag
//for all your view field
query.ViewFields ="<FieldRef Name='ID'/>"

To specify the row limit use:

query.RowLimit = 100;

To specify the scope:

query.ViewAttributes = "Scope=\"RecursiveAll\""

To specify Joins:

query.Joins = "";



Take a look to these links:

CAML query join

  • Thanks @NK SP for your reply but why I need to re assign view fields and row limit as I did assign them in CAML query showed . Regarding links you showed I think these limitation not applied with my case . By the ways this code worked successfully before but without last update which is join and projected fields . Commented Apr 26, 2015 at 17:06
  • Even if the question is old, he has not to pass an SPQuery, since he is using CSOM and not the server api. CSOM has no Query, ViewAttributes, Joins and ViewAllFields properties.
    – Emaborsa
    Commented Mar 6, 2020 at 7:50

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.