I want to get the date / time stamp for the last item was added / updated to SharePoint site using JavaScript. Is there any API in JS to do so?
Thanks.
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityCheck the http://yoursite/_api/web
It will returns the attribute called "LastItemModified".
Just make a GET request to following URL.
{site url}/_api/web/LastItemModifiedDate
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/LastItemModifiedDate",
type: "GET",
headers: {
"accept": "application/json;odata=verbose",
},
success: function(data) {
console.log(data.d.LastItemModifiedDate);
},
error: function(error) {
alert(JSON.stringify(error));
}
});
let url = 'http://www.example.com/yourweb/_api/web/lists/getbytitle(\'Member Your List Name\')/LastItemModifiedDate'; fetch(url,{ method:'get', credentials:'include', headers:{ "Accept":"application/json;odata=nometadata" } }) .then(res => res.json()) .then(json => console.log(json.value)) .catch(error => console.error("Caught Error\n",error))
May 16, 2019 at 15:05
(in Chrome) Install the SharePoint Insider plugin:
https://chrome.google.com/webstore/detail/sharepoint-insider/gjckpigahcbffmeofjfedlffddhfidhj
Browse to a (Sub)Web
See the 2 LastItem** fields with the info you (might) want
Use the JSON tab to learn how to call the API
I am surprised nobody mentioned the difference between the LastItemModifiedDate
and LastItemUserModifiedDate
. The latter property was added later by Microsoft to reflect changes made by user accounts only. The former property was influenced by changes made by the system.
REST call:
sites/.../_api/web/LastItemUserModifiedDate
Read about it here:
Modified dates in Site Contents should reflect content changes, not system changes.
/_api/web/lists/getbytitle('your list')/LastItemModifiedDate
May 16, 2019 at 14:58