2

I am trying to find an API that retrieves all comments from "Append-Only Comment" field. I couldn't find one API that would return all the previous comments, modified date, and the modified-by user. API that returns data from change log only returns the last comment and GetListItemChangeSinceToken API call only returns the last change even when there are more than one change happened since the last token. The version history required parsing html which I prefer not to use. If you happen to know an API call that could possibly solve my problem, please let me know. I would really appreciate it. Thanks!

1 Answer 1

0

Get request to Versions page:

http://<server>/<site>/_layouts/versions.aspx?list={listID}&ID=<itemID>


function getItemVersions(url,listId,itemId,success)
{
   var versionsUrl = url + '/_layouts/versions.aspx?list=' + listId + '&ID=' + itemId;  
   $.get( versionsUrl, function( data ) {
      var versionEntries = parseVersionList(data);
      success(versionEntries);
   });
}


function parseVersionList(data){
   var entries = {};
   var versionList = $(data).find('table.ms-settingsframe');


   versionList.find('tbody > tr').each(function(i){
     if(i > 0 && (i-1) % 2 == 0) {
        var verRow = $(this); //get version row
        var propsRow = verRow.next(); //get properties row
        var versionLabel = verRow.find('td:first').html().trim();
        entries[versionLabel] = {};
        //extract item properties from propsRow goes here
        //...
     }

   });   
   return entries;
}


//Usage
var webUrl = _spPageContextInfo.webAbsoluteUrl;
var listId = _spPageContextInfo.pageListId;
var listItemId = 1;
getItemVersions(webUrl,listId,listItemId,function(versionEntries){
  console.log(versionEntries);
});
1
  • 1
    Thanks for the suggestion! I already tried this request but this requires parsing HTML which I prefer not to use
    – Judy Jeong
    Feb 20, 2018 at 19:39

Your Answer

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

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