2

I am using the following to get changes that happened in a Site Collection.

ChangeToken token = new ChangeToken();
token.StringValue = lastChangeToken;

ChangeQuery query = new ChangeQuery(true, true);
query.ChangeTokenStart = token;

ChangeCollection changecol = site.GetChanges(query);
context.Load(changecol);
context.ExecuteQuery();

This returns all the changes since the last change token.

I want only the very latest change to get the Site Collection's updated last change token. So, I am looking for something that returns only the last change rather than getting all changes as there might be a considerable time difference.

I tried query.FetchLimit = 1; query.LatestFirst = true; but got error as "Specified method is not supported." while ExecuteQuery. I even tried to use ChangeLogItemQuery but site.GetChanges does not accept it.

  • CSOM only? perhaps powershell: $listTitle = "Test" $list = $context.Web.Lists.GetByTitle($listTitle) $qry = new-object Microsoft.Sharepoint.Client.ChangeQuery($true,$true) $changes = $list.GetChanges($qry) $context.Load($changes) $context.ExecuteQuery() $changes | select ChangeType, Time – user37251 Sep 15 '17 at 14:46
  • This is the powershell version of CSOM. However this still requests all changes from the sharepoint made to the list. ($context.Load($changes)) . But, I want to form a query that requests only the latest change to sharepoint itself. – Shen Prabu Sep 15 '17 at 15:07
1

The following code snippet will get all the changes to a site collection:

ChangeQuery siteCQ = new ChangeQuery(true, true);  
var siteChanges = site.GetChanges(siteCQ);  
clientContext.Load(siteChanges);  
clientContext.ExecuteQuery();

foreach (Change change in siteChanges)  
{
 Console.WriteLine("{0}, {1}", change.ChangeType, change.TypedObject);
}

Source

  • Please.. This is what I do currently. But I want to get only the latest change without requesting all changes to server. – Shen Prabu Sep 15 '17 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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