1

I want to extract the "lastModifiedDateTime" from a list. I don't want to search the list by ID, but rather from its name. I know you can do it by MS graph, but the examples needs site ID as well as List ID. I want it in this similar form (tested in MS Graph explorer):

const SiteUrl = this.context.current.Web.Url;

SiteUrl+"/Lists/Project%20Information/AllItems.aspx/lastModifiedDateTime"

Does not work. Notice I want to use the current URL and hardcoded path (since all list have the same ending/name in the URL from provisioning, but the ID is different).

Is there any way I can use MS Graph to get the lastModifiedDateTime by site and list NAME and not ID? Or with Rest.

1 Answer 1

3

You could use SP API _api/web/Lists/GetByTitle('listName') endpoint which returns list informations and deal with LastItemDeletedDate and LastItemModifiedDate. Here's a working code:

var requestUri = _spPageContextInfo.webAbsoluteUrl + '/_api/web/Lists/GetByTitle(\'stuff\')';
xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
    if (this.readyState == XMLHttpRequest.DONE) {
        if(this.status == 200) {
            res = JSON.parse(this.responseText);
            console.log(res);
            console.log(res.d.LastItemModifiedDate);
        }
        else {
            console.log('Err. Could not return data.');
        }
    }
};

xhr.open('GET', requestUri, true);
xhr.setRequestHeader('accept', 'application/json;odata=verbose');
xhr.send(); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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