I wrote this code which loops through the Site Collection, from each site, gets the list collection (only document libraries), from there looks through each item in the document library for items which are currently checked out but only have version 1.
This CAMLQuery doesn't work though: '<Query><Where><And><Eq><FieldRef Name="_UIVersionString" /><Value Type="Text">1.0</Value></Eq><IsNotNull><FieldRef Name="CheckoutUser" /></IsNotNull></And></Where></Query>'
It shows me only MY files which have no checked in version and other files which are fine. At this point, I think the only issue is getting the CAMLQuery right.
This CAMLQuery doesn't work though: '<Query><Where><And><Eq><FieldRef Name="_UIVersionString" /><Value Type="Text">1.0</Value></Eq><IsNotNull><FieldRef Name="CheckoutUser" /></IsNotNull></And></Where></Query>'
It shows me only MY files which have no checked in version and other files which are fine. At this point, I think the only issue is getting the CAMLQuery right.
var fileCount = 0;
var limboData = [];
function XgetAllSites(){
$().SPServices({
operation: "GetAllSubWebCollection",
async: false,
completefunc: function(xData, Status){
site = $(xData.responseXML);
site.find('Web').each(function(){
var siteName = $(this).attr('Title');
var siteUrl = $(this).attr('Url');
Xgetlists(siteUrl);
console.log("At Sites: "+ siteName);
});
}
});
console.log(limboData);
limboReport(limboData);
}
function Xgetlists(siteUrl){
$().SPServices({
operation: "GetListCollection",
webURL: siteUrl,
async: false,
completefunc: function(xData, Status){
$(xData.responseXML).find("List[ServerTemplate='101']").each(function(){
var listName = $(this).attr('Title')
var listId = $(this).attr('ID');
XgetListItems(listId, siteUrl)
console.log("At list: "+ listName);
});
}
});
}
function XgetListItems(listId, siteUrl){
$().SPServices({
operation: "GetListItems",
webURL: siteUrl,
listName: listId,
CAMLViewFields: "<ViewFields Properties='True' />",
CAMLQuery: '<Query><Where><And><Eq><FieldRef Name="_UIVersionString" /><Value Type="Text">1.0</Value></Eq><IsNotNull><FieldRef Name="CheckoutUser" /></IsNotNull></And></Where></Query>',
async: false,
completefunc: function (xData,Status){
$(xData.responseXML).SPFilterNode("z:row").each(function() {
var fileName = $(this).attr('ows_LinkFilename');
var fileUrl = $(this).attr('ows_FileDirRef').split("#");
var checkedTo = $(this).attr('ows_LinkCheckedOutTitle');
var modified = $(this).attr('ows_Modified');
limboData.push({
fileName: fileName,
fileUrl: fileUrl[1],
checkedTo: checkedTo,
modified: modified
});
fileCount++;
console.log("At list items. File Found: "+ fileName);
});
}
});
}
function limboReport(o){
var header = "<tr><th>File Name</th><th>Location</th><th>Owner</th><th>Modified</th></tr>";
$('#limboReport thead').append(header);
var row = "";
for (var i=0;i<limboData.length;i++){
row += "<tr id='" + i + "'><td class='firstColumn'>" + o[i].fileName + "</td><td><a target='_blank' href='"+rootSite+'/'+o[i].fileUrl+"'>" + o[i].fileUrl + "</a></td><td>" + o[i].checkedTo+ "</td><td>" + o[i].modified + "</td></tr>";
};
$('#limboReport tbody').append(row);
}