Pregunta

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

¿Fue útil?

Solución 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>

enter image description here

Otros consejos

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.

Licenciado bajo: CC-BY-SA con atribución
scroll top