CSOM Sharepoint sites Change Log
Very often we need to gather information on SharePoint site/web changes after a specific period. Specially We found it very useful to trace any modification done on a site post migration and in case incremental job to be run one can easily identify what are the new changes will be lost after the migration.
In order to do so we need to do the following
To gather the site level changes
Initialize the below variables as required.
Site rootSite;
ClientContext context;
DateTime dateTime;
string format = "1;1;{0};{1};-1";
ChangeQuery cq = new ChangeQuery(true, true);
cq.ChangeTokenStart = new ChangeToken()
{
StringValue = string.Format(format, rootSite.Id, dateTime.Ticks)
};
ChangeCollection changeCol = rootSite.GetChanges(cq);
context.Load(changeCol);
context.ExecuteQuery();
while (changeCol.Count > 0)
{
//DO THE PROCESSING TO GATHER ALL THE REQUIRED INFO LIKE SITE NAME, ID, CHANGW TYPE etc.
}
At we level the process is same instead of Site instance we need to consider the instance of a specific WEB.
Different type of changes that can be gathered using the above approach are listed below, all are Out of the box .NET classes available under the Microsoft.SharePoint.Client namsespace
1.ChangeSite
2.ChangeItem
3.ChangeField
4.ChangeList
5.ChangeFolder
6.ChangeView
7.ChangeWeb
8.ChangeContentType