Domanda

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.

È stato utile?

Soluzione

Check the http://yoursite/_api/web

It will returns the attribute called "LastItemModified".

Altri suggerimenti

Just make a GET request to following URL.

{site url}/_api/web/LastItemModifiedDate

Example using jQuery

$.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));
    }
});

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top