Tuesday, May 19, 2009

Difference between Update and SystemUpdate in Sharepoint

We all know that whenever we add a list item or do some modification, we update the list. Here we have two options:

1. List.Update() and 2. List.SystemUpdate()

The main difference betwwen two is that,

List.Update() creates automatically new version of list item as Update method is called.


List.SystemUpdate() avoids SharePoint 2007 to change modified date and modifier fields. Argument false tells that no new versions are expected.

SystemUpdate takes an boolean argument that set whether new version need to be created or not.

Example using SystemUpdate() :

SPList list = web.Lists["myList"];
SPListItem item = list.Items[0];
item["myField"] = "my value";

item.SystemUpdate(false);
list.Update();

3 comments:

Manab Ranjan Basu said...

Thanks Varun ,This is a Very useful blog you have created.I think it will help lot of people to learn Sharepoint as well as .NET

gitolekha said...

Great. Your post cleared my confusion I had since a long time.

Thanks
Gitolekha Ray
http://techolyvia.wordpress.com/

Anonymous said...

Also, Alert emails will not be triggered on SystemUpdate(). Thought it might be useful for someone.