1

I know PowerShell will do this, but I don't have access. So just using javascript, is there a script that can do item count, date modified, library or list, URL, and times viewed for all lists and libraries in a site?

enter image description here

1

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.

1

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>

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.