3

i am trying to get the comments from Comment List in a 'Descending' order , the query that i am using is :

"<Where>" +
  "<Eq>" +
    "<FieldRef Name='TopicID' /><Value Type='Text'>" + ProjectID + "</Value>" +
  "</Eq>" +
  " <OrderBy>"+
    "<FieldRef Name='Created' Ascending='False' />"+
  " </OrderBy>"+  
"</Where>";

but this query gives me the result in 'Ascending' order even if i set it to false. what is wrong here?

  • Ignore my previous comment - the formatting in you question didn't make me notice the wrong nesting of the tags. – SPArchaeologist Feb 14 '16 at 12:07
5

OrderBy should be outside of the Where clause. Try modifying your query to this:

"<Where>" +
 "<Eq>" +
    "<FieldRef Name='TopicID' /><Value Type='Text'>" + ProjectID + "</Value>" +
   "</Eq>" +
"</Where>" +
      " <OrderBy>"+
   "<FieldRef Name='Created' Ascending='False' />"+
       "</OrderBy>" ;

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.