GetListItems Recursive - SubFolders

Jun 10, 2014 at 3:58 PM
Hi, I'm looking for a little help before I pull out the last two hairs on my head.

All I want to accomplish is to get the results of all items in a list that have the name Acura in the Program column.

All the data is the Pages Library under various folders. I have spend hours trying to look through the site and Google trying to find something that works. So far, nothing works.

Any help would be appreciated. Thank You!!

function tryAgain6(){
filePath = "CCUR/knowledge/Pages/";
listName = "{929DB3B3-BCD4-4AD2-AC82-7B0B8D0703F8}";

$().SPServices({
operation: "GetListItems",
async: false,
//webURL: filePath,
listName: listName,
CAMLQuery: "<Query><Where><Eq><FieldRef Name='Program' /><Value Type='Choice'>Acura</Value></Eq></Where></Query>",
CAMLViewFields: "<ViewFields><FieldRef Name='Program' /><FieldRef Name='EncodedAbsUrl' /><FieldRef Name='ContentType' /><FieldRef Name='Modified' /><FieldRef Name='FileRef ' /></ViewFields>",
CAMLQueryOptions: "<QueryOptions><IncludeMandatoryColumns>False</IncludeMandatoryColumns><ViewAttributes Scope='RecursiveAll' /><Folder>/CCUR/knowledge/Pages/Matrices/Roadside</Folder></QueryOptions>",
completefunc: function (xData, Status) {
    listLen = $(xData.responseXML).SPFilterNode("z:row").length;
    alert("itemCount = " + listLen);

    $(xData.responseXML).SPFilterNode("z:row").each(function() {
        itemProgram = $(this).attr("ows_Program");
        alert(itemProgram);
    });
}   
});
}
tryAgain6();
Jun 10, 2014 at 11:00 PM
Do you get anything back if you remove Folder from CAMLQueryOptions?

I seem to remember some trouble with using it along with recursive.




--
Paul T.

-- Sent from Mobile

Coordinator
Jun 10, 2014 at 11:44 PM
Yes, I think you just want this:
CAMLQueryOptions: "<QueryOptions><ViewAttributes Scope='RecursiveAll' /></QueryOptions>",
While IncludeMandatoryColumns is appealing, I've never seen it work.

M.
Jun 11, 2014 at 10:38 AM
Thanks for the help Paul. I removed the Folder from the QueryOptions, and I'm still displaying 0 items.
Jun 11, 2014 at 10:41 AM
Edited Jun 11, 2014 at 11:06 AM
Hi M. I simplified by CAMLQueryOptions like you suggested. Unfortunately, I'm still displaying 0 items.

Here is a new update of my code.

Thanks for all your help.
function tryAgain7(){
filePath = "CCUR/knowledge/Pages/";
listName = "{929DB3B3-BCD4-4AD2-AC82-7B0B8D0703F8}";

$().SPServices({
    operation: "GetListItems",
    async: false,
    listName: listName,
    CAMLQuery: "<Query><Where><Eq><FieldRef Name='Program' /><Value Type='Choice'>Acura</Value></Eq></Where></Query>",
    CAMLViewFields: "<ViewFields><FieldRef Name='Program' /><FieldRef Name='EncodedAbsUrl' /><FieldRef Name='ContentType' /><FieldRef Name='Modified' /><FieldRef Name='FileRef ' /></ViewFields>",
    CAMLQueryOptions: "<QueryOptions><ViewAttributes Scope='RecursiveAll' /></QueryOptions>",
    completefunc: function (xData, Status) {
        listLen = $(xData.responseXML).SPFilterNode("z:row").length;
        alert("itemCount = " + listLen);

        $(xData.responseXML).SPFilterNode("z:row").each(function() {
            itemProgram = $(this).attr("ows_Program");
            alert(itemProgram);
        });
    }   
});
}
tryAgain7();
Coordinator
Jun 11, 2014 at 11:23 AM
Edited Jun 11, 2014 at 11:24 AM
My suggestion would be to back off on your filtering and ViewFields so that you can retrieve some items, then add the filtering back in. Also, have you looked at the traffic in Firebug or Fiddler? It may well be that you are getting errors. For instance, you may have a column name wrong.

M.
Jun 11, 2014 at 12:05 PM
Thanks M.
I just opened Fiddler and took a look at the results. You right, I was getting an error. It appears my list is exceeding the 5,000 record threshold. I tried the script on another list that does not have this same error and the script is returning the correct values. Looks like I have some other issues to take care of first.
soap:ServerException of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator.0x80070024
Thanks for all your help.

Cheers.
-jeffrey
Coordinator
Jun 11, 2014 at 12:54 PM
Well, at least you know what the problem is now.

M.
Jun 11, 2014 at 1:05 PM
And it not an easy problem to resolve/get around... :)

_________
Paul T