How to get SharePoint list last updated details using REST
SharePoint list last updated details using REST
You can use the below code to get last updated date of a SharePoint list which may be used in your any BAU requirement.
Code -
function lastItemModified(){
$.ajax({
url: url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/GetByTitle('Dummy')/Items?$select=Modified&$orderby= Modified desc",,
method: "GET",
headers: {
"Accept": "application/json; odata=verbose"
},
async: false,
success: function success(data) {
var d = data.d.results[0].Modified.substring(0, data.d.results[0].Modified.lastIndexOf("T"));
var year = d.split("-")[0];
var month = d.split("-")[1];
var day = d.split("-")[2];
var html = "<i>Last Updated: </i>" + month +"/"+ day +"/"+ year;
$("#last_updated").html(html);
},
error: function(error) {
alert(JSON.stringify(error));
}
});
}
Add caption |
Comments
Post a Comment