none
List.GetChanges returns no changes

    Question

  • HI,

       I have the following code which tries to get change logs from a list using client object model. It returns no changes in changecollection on some environments but works fine on other envs. See the line in code highlighted.

    I also checked the "changelogexpirationperiod" which is well set to 60 days. I even disabled the changelog expiration but no success.

    Does anyone know whats going on??

     ClientContext context = new ClientContext("someurlhere");

     

     

    ChangeQuery changeQuery = new ChangeQuery(false, true

    );

    changeQuery.List =

    true

    ;

     

     

    Web

    web = context.Web;

     

    List list = context.Web.Lists.GetByTitle("DemoList"

    );

    context.Load(list);

     

    ChangeCollection

    changes = list.GetChanges(changeQuery);

    context.Load(changes);

    context.ExecuteQuery();

     

    foreach (Change change in

    changes)

    {

    }

    }

    Thanks,

    Manvir


    Manvir
    Tuesday, October 04, 2011 12:52 AM

All replies

  • Hi Manvir,

    SPList.getChanges() and SPSite.getChanges() is related with the Change Log timer job, it may returns no changes after running Change Log timer job. Here is a similar thread that is solved by modify the value of @IgnoreChangeNumberIfNotFound in the query when calling getChanges(), you can refer to it for more information:
    http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/ac7e2e85-a223-4ec3-b06f-d5846b79e604

    Thanks,
    Qiao

    Wednesday, October 05, 2011 7:36 AM
    Moderator
  • Thanks Qiao. how i can change the value of @IgnoreChangeNumberIfNotFound ?
    Manvir
    Thursday, October 06, 2011 11:36 PM
  • The value of the @IgnoreChangeNumberIfNotFound  variable can be change by altering the stored procedure on the server.

    Is there any other solution to this apart from doing that? (Modifying that Sproc is a bad idea IMO - who knows what bad things will happen as a result of doing that)

    Friday, June 29, 2012 8:00 PM
  • Any new information on this problem?
    Thursday, November 29, 2012 4:32 PM
  • Instead of changing the stored procedure, I found a different approach which seems to be working just fine. As the "Change Log timer job" seems to cause the trouble I looked up what it's doing and the purpose is to delete events older than 60 days. So when calling GetChanges on anything like SPWeb, SPList .. it doesn't make sense to try to get changes older than 60 days. So instead of calling GetChanges without any parameter you start create a changetoken and receive all changes from the last 60 days.

    DateTime startTime = DateTime.UtcNow.AddDays(-60);
    
    SPChangeToken startToken = new SPChangeToken(SPChangeCollection.CollectionScope.Web,webSite.ID, startTime);
    
    SPChangeCollection changes = webSite.GetChanges(startToken);

    I found the code on this Microsoft Website. So with this code no changes to the stored procedure are required. Although I still think it's some kind of a bug!

    Friday, November 30, 2012 7:40 AM