I have about 10 Document folders in my list 'ZooLibrary' and

I would like Query to display all the PowerPoint files title from the folders in the list, sorted by ID.

Currently, my View Scope='RecursiveAll' isn't working, any idea why?

<SCRIPT type=text/javascript> get() ;
function get() { var method = "GetListItems";                 
var webURL =  $().SPServices.SPGetCurrentSite() ;                     
var list = "ZooLibrarySlides";                      
var fieldsToRead = "<ViewFields>"+"<FieldRef Name='Name' />" +"</ViewFields>";
var query = "<Query><Where><Neq><FieldRef Name='ContentType' /><Value Type='Text'>Folder</Value></Neq></Where><OrderBy><FieldRef Name='Modified' Ascending='False' /></OrderBy></Query>";

({ operation: method, async: false, webURL: webURL, listName: list,
CAMLViewFields: "<ViewFields Properties='True' />",
CAMLRowLimit: 8,
CAMLQueryOptions: "<QueryOptions><ViewAttributes Scope='RecursiveAll' /></QueryOptions>",
CAMLQuery: query, completefunc: function (xData, Status)
{ $(xData.responseXML).SPFilterNode("z:row").each(function() { 

if($(this).attr("ows_DocIcon")== "pptx")
var title = $(this).attr("ows_Title");
$("#ISDataTable").append("<tr align='middle'>" +
"<td align='left' class='tooltip'>" +title+ ""</td>" + "</tr>");
}); } 
}); }; 

Add CAMLQueryOption to GetListItems call,

CAMLQueryOptions: "<QueryOptions><ViewAttributes Scope='RecursiveAll'/></QueryOptions>"

Update your CAMLQuey,

CAMLQuery: "<Query> <Where> <Neq><FieldRef Name='ContentType' /><Value Type='Text'>Folder</Value></Neq> </Where> <OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy></Query>",

Use below logic inside the completefunc for each iteration,

        operation: "GetListItems",
        async: false,
        listName: "ZooLibrarySlides",
        CAMLQuery: "<Query> <Where> <Neq><FieldRef Name='ContentType' /><Value Type='Text'>Folder</Value></Neq> </Where> <OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy></Query>",
        CAMLQueryOptions: "<QueryOptions><ViewAttributes Scope='RecursiveAll'/></QueryOptions>",

        completefunc: function (xData, Status) {        
            $(xData.responseXML).SPFilterNode("z:row").each(function() { 
                if($(this).attr("ows_DocIcon")== "pptx")
  • However, the files displayed are folders and not the powerpoint slides within the folders? – John Lee Dec 8 '17 at 6:35
  • @JacksonLim check the updated answer – Vishnu S Dec 8 '17 at 7:26
  • Hi Vishnu, I have updated the above code. Really thanks for the help, unfortunately the folder search was stuck at the first level folders, I have folders within folders :( . The PowerPoint slides inside the folders wasn't showing up as well. – John Lee Dec 8 '17 at 8:20
  • The code works for me. Try to remove CAMLRowLimit from your code. Also check the result xml using, console.log(xData.responseText) inside completefunc. – Vishnu S Dec 8 '17 at 8:25
  • It's getting feedback! Just 1 question, i tried replacing the alert powerpoint with my append code. Why it doesn't work? – John Lee Dec 8 '17 at 9:15

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.