Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am using the GetVersionCollection to get the history information from my list. This seems to be working fine; however, what I need to do is get the version history of the individual item which has been changed in the SharePoint list. From what I can understand on the web service call, it goes by individual list item and the version of that item. Is there a way to get the information of the list item which has been changed? I need this to work like the View History in SharePoint but what I am trying to do is view all version changed for all items based on date instead of one at a time. Here is what I have done so far:

<script type="text/javascript" language="javascript">

$(document).ready(function() {

var proID = new Array();
var proTitle = new Array();
var proModified = new Array();
var proHistory = new Array();
var i = 0;

$().SPServices({
   operation: "GetListItems",
   async: false,
   listName: "NewProjects",
   webURL: "http://devchrisl01/test",
   //CAMLQuery: '<Query><Where><Eq><FieldRef Name="ProjectOpen" /><Value Type="Boolean">1</Value></Eq></Where><OrderBy><FieldRef Name="Title" Ascending="True" /></OrderBy></Query>',
   CAMLViewFields: '<ViewFields><FieldRef Name="Title" /><FieldRef Name="ID" /><FieldRef Name="Modified" /><FieldRef Name="History" /></ViewFields>',

   completefunc: function(xdata, status) 
   {

            //alert(xdata.responseXML.xml);
        $(xdata.responseXML).SPFilterNode("z:row").each(function() {


            var xitem = $(this);
            var ID = xitem.attr('ows_ID');
            var Title = xitem.attr('ows_Title');
            var Modified = xitem.attr('ows_Modified');
            var History = xitem.attr('ows_History');

           //alert(ID);
            proID[i] = ID;
            proTitle[i] = Title;
            proModified[i] = Modified;
            proHistory[i] = History;
            i++;

            });

   }

});





for (i=0; i < proID.length; i++){

$().SPServices({
  operation: "GetVersionCollection",
      async: false,
      webURL: "http://devchrisl01/test",
      strlistID: "NewProjects",
      strlistItemID: proID[i].toString(),
      strFieldName: "History",
      completefunc: function (xdata, Status) {


        $(xdata.responseText).find("Version").each(function() {

       //alert(xdata.responseXML.xml);

            var xitem = $(this);
            var ID = xitem.attr('ID');
            var Title = xitem.attr('Title');
            var Modified = xitem.attr('Modified');
            var History = xitem.attr('History');


                //var data = "<tr><td>" + proID[i].toString() + "</td><td>" + proModified[i].toString() + "</td><td>" + proTitle[i].toString() + "</td></tr>";
                var data = "<tr><td>" + proID[i] + "</td><td>" + Modified + "</td><td>" + History + "</td><td>" + proTitle[i] + "</td></tr>";

                $('#tester').append(data);


        });  

      }

   });

  }

});


</script>

</head>

<body>

<form id="form1" runat="server">

<table id="tester" cellpadding="5px"><th>Project Number</th><th>Modified</th><th>History</th><th>Project Name</th></table>  
</form>

</body>

</html>

I am getting the information back for each list item doing it this way, the only thing missing is the information of the list item which has been changed. I only want the list items to show if the item has been changed. Doing it this way, I am getting everything back. I hope I am being clear on what I am trying to do. Thanks for the Views!!

share|improve this question

1 Answer 1

To get a list of which Items has changed since a certain time you can use Lists.GetListItemChanges, but to get the individual changes you have to loop through the Version History and build it up.

share|improve this answer
    
I am not going to be able to put a time into the code. This would work, but my big caveot is not being able to hard code a date. Thank you for the response :) –  lazoDev Apr 17 '12 at 13:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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