TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Retrieve the Changes Occurred on the List Item using CSOM
Shantha Kumar T
Dec 31
2015
Code
4.2
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
//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();
}
Retrieve the Changes Occurred on the List Item
List
CSOM
SharePoint