Updating SPListItem without changing versions

The below snippet is usually used to update SPListItems. The Item.Update() updates the database with the changes, creates a new version and changes the Modified and Modified By fields.

SPList list = web.Lists["List1"];
SPListItem item = list.Items[0];
item["Field1"] = “Test”;

item.Update();
list.Update();

If you want to avoid version changes, Modified and Modified By fields from getting updated , Item.SystemUpdate() would be the right way to do it.
SPList list = web.Lists["List1"];
SPListItem item = list.Items[0];
item["Field1"] = “Test”;

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

The argument false informs the SP object Model not increment versions.

Advertisement

~ by lucidperplexity on December 12, 2008.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.