0

Consider this as my code to retrieve an Announcements List from SharePoint 2010 site:

<Query>
<Where>
  <Or>
     <Or>
     <Eq>
      <FieldRef Name="Title"></FieldRef>
      <Value Type="Text"></Value>
     </Eq>
     <Eq>
      <FieldRef Name="Dream_x0020_Destination" />
      <Value Type="Text"></Value>
     </Eq>
    </Or>      
      <IsNotNull>
      <FieldRef Name="PPP"  Ascending="False"></FieldRef>
      <Value Type="Currency"></Value>
      </IsNotNull> 
    </Or>
</Where>
<OrderBy>
<FieldRef Name="PPP"  Ascending="False"></FieldRef>
</OrderBy>
</Query>

This query is generating an error:

System.Web.Services.Protocols.SoapException: Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown. at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) at SPCAMLQueryHelper.SPWSLists.Lists.GetListItems(String listName, String viewName, XmlNode query, XmlNode viewFields, String rowLimit, XmlNode queryOptions, String webID) at SPCAMLQueryHelper.WebServiceWork.ExecuteQuery.Worker()

  • 2
    How are you calling the code? With CSOM or SSOM? – Robert Lindgren Sep 8 '15 at 6:56
  • 1
    Also, you shoud not have the <Value> part in an <OrderBy> statement – Robert Lindgren Sep 8 '15 at 6:58
  • I am using CSOM to call this query. I am not deploying anything on Server. Actually I am testing this query using CAML Query Helper and the error mentioned above is shown in CAML Query Helper. I removed the <Value> part from the <OrderBy> statement. Results are same – Yash Saraiya Sep 8 '15 at 7:03
  • 1
    You are also not passing any values in any of your <Eq> statements, and you should not wrap your <IsNotNull>:s in <Eq> tags – Robert Lindgren Sep 8 '15 at 7:10
1

There are multiple errors in the query:

  • You don't need Value in OrderBy
  • You have IsNotNull inside Eq
  • You have Ascending attribute in FieldRef for IsNotNull
  • You have no values in Eq conditions. Consider using IsNull (unless you've just omitted values in the question).

Try this one:

<Query>
 <Where>
  <Or>
   <Or>
    <Eq>
     <FieldRef Name="Title"/>
     <Value Type="Text"></Value>
    </Eq>
    <Eq>
     <FieldRef Name="Dream_x0020_Destination" />
     <Value Type="Text"></Value>
    </Eq>
   </Or>
   <IsNotNull>
    <FieldRef Name="PPP"/>
   </IsNotNull>
  </Or>
 </Where>
 <OrderBy>
  <FieldRef Name="PPP" Ascending="False"/>
 </OrderBy>
</Query>
  • Thank you for your valuable feedback and great example of a working query. – Yash Saraiya Sep 8 '15 at 7:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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