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?

Kaushal Khamar
  • 1,382
  • 2
  • 13
  • 32

2 Answers2

5

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\"> " 
TARUN
  • 2,856
  • 20
  • 45