Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

New Post: Can't get CAMLRowLimit working

$
0
0
Hi Marc,

I have been searching the internet longer than I would like to admit and I finally found a fix for my issue in a previous post on the discussion board. http://spservices.codeplex.com/discussions/266636 Adding a query solved my problem regardless of whether I had the CAMLRowLimit specified or not.

Since I have spent so much time on this web part I thought I would share it. If you paste the below code into a CEWP it will loop through all lists and libraries on that site and give you a nice report of all files within that site. I had a client request this to clean up their SharePoint environment before upgrading to SharePoint 2013. I hope this helps others in "clean up" efforts or migrations to SP 2013.
<script type="text/javascript" src="/FilePath/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/FilePath/jquery.SPServices-0.7.2.min.js"></script>
<script language="javascript" type="text/javascript">

$(document).ready(function() {

var metricsHtml= "<table><tr><td width='150'>List Name</td><td width='300'>File Name</td><td>File Ext</td><td width='150'>File Size</td><td width=150'>Last Modified</td><td width='150'>Created By</td><td width='150'>Created Date</td><td>File Path</td></tr>";

$("#myDiv").append(metricsHtml);

$().SPServices({
operation:"GetListCollection",
async:false,
completefunc: function(xData, Status) {
$(xData.responseXML).find("List[ServerTemplate='101'],[ServerTemplate='109'],[ServerTemplate='115']").each(function(){
listName = $(this).attr("Title");

//While looping through the lists pass the listName to the GetListItems operation to get details about the list items

$().SPServices({
operation: "GetListItems",
async: false,
listName: listName,
CAMLViewFields: "<ViewFields><FieldRef Name='Name'/><FieldRef Name='FileSizeDisplay'/><FieldRef Name='Modified'/><FieldRef Name='Author'/><FieldRef Name='Created'/><FieldRef Name='Path'/></ViewFields>",
CAMLQueryOptions: "<QueryOptions><ViewAttributes Scope='Recursive'/></QueryOptions>",
CAMLQuery: "<Query><Where><Neq><FieldRef Name='ID' /><Value Type='Counter'>0</Value></Neq></Where></Query>",

completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {

var fileSize = $(this).attr("ows_FileSizeDisplay");
var name = $(this).attr("ows_FileLeafRef");
var cln = name.indexOf("#");
var clnName = name.substring(cln+1);
var author = $(this).attr("ows_Author");
var authorCln = author.indexOf("#");
var clnAuthor = author.substring(authorCln+1);
var urlPath = $(this).attr("ows_FileRef");
var urlPathCln = urlPath.indexOf("sites");
var clnUrlPath = urlPath.substring(urlPathCln+6);
var lastSlash = clnUrlPath.lastIndexOf("/");
var folderPath = clnUrlPath.substr(0, lastSlash + 1);
var fndExtention = clnUrlPath.lastIndexOf(".");
var fileExtention = clnUrlPath.substr(fndExtention + 1);

metricsHtml = "<tr><td>" + listName + "</td><td>" + clnName + "</td><td>" + fileExtention + "</td><td>" + fileSize + "</td><td>" + $(this).attr("ows_Modified") + "</td><td>" + clnAuthor + "</td><td>" + $(this).attr("ows_Created") + "</td><td>" + folderPath + "</td></tr>";

$("#myDiv table").append(metricsHtml);

}); // end each
} // end completefunc
}); // end spservices
}); // end each
} // end completefunc
}); // end spservices
}); // end ready function


</script>
<div id="myDiv"/>
Thanks,
Dan

Viewing all articles
Browse latest Browse all 6517

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>