//CSOM Assembly version - 16.1.4727.1200
//using Microsoft.SharePoint.Client;
//using System.Net
//GetItemChanges(credentials, weburl, listtitle, itemid);
//This method returns all the changes (add, update & delete) happened to the list item
private static void GetItemChanges(ICredentials credentials, string weburl, string listTitle, int itemid)
{
using (ClientContext ctx = new ClientContext(weburl))
{
ctx.Credentials = credentials;
Web oweb = ctx.Web;
ListCollection lists = oweb.Lists;
List targetList = lists.GetByTitle(listTitle);
ListItem targetItem = targetList.GetItemById(itemid);
//ChangeQuery helps the method gets the changes by setting appropriate property as true
ChangeQuery cq = new ChangeQuery();
cq.Item = true;
cq.Add = true;
cq.Update = true;
cq.DeleteObject = true;
//SP.ListItem.GetChanges(ChangeQuery) - Method available from CSOM Assembly version - 16.1.4727.1200
ChangeCollection cc = targetItem.GetChanges(cq);
ctx.Load(cc);
ctx.ExecuteQuery();
Console.WriteLine(cc.Count.ToString());
}
Console.WriteLine("Press any key to exit...");
Console.Read();
}This code snippet used to get the collection of changes occurred on the list item using CSOM.
