1

Hi i have document library having custom column named INDEX of type Number and there is some folders and documents in document library like

File/folder structure in document library

I have created CAML query to get item having maximum Index value.

query += "<Where>";
query += "<IsNotNull>";
query += "<FieldRef Name='INDEX'/>";
query += "</IsNotNull>";
query += "</Where>";
query += "<OrderBy >";
query += "<FieldRef  Name='INDEX' Ascending='FALSE' />";
query += "</OrderBy>";

itemQuery.Query = query; 

In result i am getting is below which is wrong.

In result all folders are displaying and then files are displaying.

enter image description here


Excepted result should be like below.

enter image description here

Can anyone help me in this issue?

4

Try adding Override="TRUE" in . Modified Code below:

query += "<Where>";
query += "<IsNotNull>";
query += "<FieldRef Name='INDEX'/>";
query += "</IsNotNull>";
query += "</Where>";
query += "<OrderBy Override="TRUE">";
query += "<FieldRef  Name='INDEX' Ascending='FALSE' />";
query += "</OrderBy>";

itemQuery.Query = query; 
0

Hi You are CSOM please kept the Scope attribute value to RecursiveAll ? If you set the scope from "Recursive" to "RecursiveAll", RecursiveAll gets all files and all folders under the specified location. please check the sharepoint stackexchange postGet Items Under Folder CAML

camlQuery.ViewXml = "<View Scope=\"RecursiveAll\"> " 
  • 1
    I don't want to get all folder and files inside folder. I want folders and files from current folder only. – Kaushal Khamar Mar 27 '17 at 6:46
  • Then use linq query on the result(list item Collection) to sort and get the first row – TARUN Mar 27 '17 at 7:05
  • 1
    That is wrong thing and will impact on performance. – Kaushal Khamar Mar 27 '17 at 7:08

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.