Is there a Javascript report for all Lists and Libraries in a site for SP 2013?
-
19-02-2021 - |
解决方案 2
I figured it out. Just post this html and JS code in a cewp on the site:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"> </script>
</head>
<body>
<input type="file" style="display:none" id="getFile"/>
<div></div><div><input type="button" id="btnSubmit" value="Get All Lists" /></div>
<div id="divResults"></div>
<div id="divAllLists"></div>
<script>
$(function () {
$("#btnSubmit").on("click", function () {debugger;
getAllLists();
});
});
function getAllLists() {
var fullUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists";
$.ajax({
url: fullUrl,
type: "GET",
headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
},
success: onQuerySucceeded,
error: onQueryFailed
});
}
function onQuerySucceeded(data) {debugger;
var listItemInfo = "";
console.log(data);
$.each(data.d.results, function (key, value) {
var type = "List";
if(value.BaseTemplate === 101){
type = "Library";
}
listItemInfo += 'Title: ' + value.Title +' Last Modified: '+new Date(value.LastItemModifiedDate)+' Item count: '+value.ItemCount+' URL :'+value.ParentWebUrl+' Type: '+type+'<br />';
});
$("#divAllLists").html(listItemInfo);
}
function onQueryFailed() {
alert('Error!');
}
</script>
</body>
</html>
其他提示
Yes, you can use JSOM (Retrieve only specified properties of lists) / Rest API (Retrieving lists and list properties with REST) to fetch the lists properties.