GetListItems No Document Records Returned

Jun 10, 2014 at 6:28 PM
Edited Jun 10, 2014 at 6:36 PM
Hi All,

I'm trying to get the document records from a document library. The problem is, only the doc set records (folders) are returned. Here's my code:
function getDocItems(srcUrl,listName)
{ 
    var itemValue = 0;
    var CAMLfields = "<ViewFields><FieldRef Name='ID' /><FieldRef Name='Title' /><FieldRef Name='ContentType' /></ViewFields>";
    jQuery().SPServices({
        webURL: srcUrl,
        operation: "GetListItems",
        async: false,
        listName: listName,
        CAMLRowLimit: 0,
        CAMLViewFields: CAMLfields,
        completefunc: function(xData, Status) {
            var strError = $(xData.responseXML).SPFilterNode('ErrorText').text();
            if(strError !== "") {
                console.log("Error updating: " + $(xData.responseXML).SPFilterNode('z:row').attr("ows_PBCOrig") + " " + strError + "");  
            } else {
                  jQuery(xData.responseXML).SPFilterNode("z:row").each(function() {
                      console.log("Id = " + jQuery(this).attr("ows_ID") + ", Title = " + jQuery(this).attr("ows_Title") + ", ContentType = " + jQuery(this).attr("ows_ContentType"));
                  }); //jQuery(xData ...
        } //if(strError ...
        } //completefunc ...
    }); //SPServices
    return itemValue;
 } // function
Here's something like what I see in the console:
LOG: Id = 12622, Title = My_Title-05-06-2014_15-54_PM, ContentType = Doc Set Type A
LOG: Id = 12610, Title = My_Title-05-06-2014_15-51_PM, ContentType = Doc Set Type B
LOG: Id = 12598, Title = My_Title-05-06-2014_15-50_PM, ContentType = Doc Set Type B

There are many documents for each of these doc sets in the library. What am I doing wrong?

Thanks in advance for any assistance!

Tim from Boston
Jun 10, 2014 at 10:56 PM
What the value if your 'myQuery' variable? Are you filtering on folders only?

Also, do you have any files under the root of the document library?

Remember that in order to get files inside all folders you must set a CAML query option that sets the filter to be done recursively through all sub-folders. I don't recall now the exact format? But I'm pretty sure it's in the documentation page for this operation (GetListItems).

Paul.




--
Paul T.

-- Sent from Mobile

Marked as answer by TimBoston on 6/11/2014 at 7:20 AM
Coordinator
Jun 10, 2014 at 11:42 PM
Check the docs for GetListItems. You need <ViewAttributes Scope="Recursive" />.

So:
CAMLQueryOptions: "<QueryOptions><ViewAttributes Scope='Recursive' /></QueryOptions>"
M.
Marked as answer by TimBoston on 6/11/2014 at 7:20 AM
Jun 11, 2014 at 2:20 PM
That worked perfectly.

Many thanks to you both!

--Tim