How to Update SharePoint List Items without Creating New Versions

Migrating data from SP2001 to MOSS2007 is fun – if you know what I mean. During migration we discovered that migration tool has some serious bugs. I wrote some code that fixes some problems after importing process. There I found a problem – I needed to update list items without getting new versions of them after updates.

Usually we see samples like this in internet:

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

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

This code works perfect for end-user scenarios. It creates automatically new version of list item as Update method is called. I needed no new versions and there fore this solution wasn’t great help for me. I found list item’s method SystemUpdate. The following code is same as the previous one but instead of Update it uses SystemUpdate.

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

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

SystemUpdate method avoids SharePoint 2007 to change modified date and modifier fields. Argument false tells that no new versions are expected. SystemUpdate solved my problem perfectly well.

Gunnar Peipman

Gunnar Peipman is ASP.NET, Azure and SharePoint fan, Estonian Microsoft user group leader, blogger, conference speaker, teacher, and tech maniac. Since 2008 he is Microsoft MVP specialized on ASP.NET.

    15 thoughts on “How to Update SharePoint List Items without Creating New Versions

    • March 24, 2008 at 1:03 pm
      Permalink

      Hello all,

      Thanks for valuable information. I was also trying to find the solution of this problem.

    • March 31, 2008 at 4:15 pm
      Permalink

      Thanks for the info. Any idea if there is a way to mark the item as dirty so it will be picked up by an incramental crawl in search? SystemUpdate works great but the changes aren’t being reflected in search until a full crawl is done.

    • April 3, 2008 at 2:06 pm
      Permalink

      Try to change modified date too before SystemUpdate().

    • May 23, 2008 at 9:36 am
      Permalink

      Be aware that if also change the Modified date, the Alerts will trigger (if you use them in your solution).

    • August 8, 2008 at 8:07 pm
      Permalink

      I want to touch the item in a list to be able to fire alerts ( for the subscribed items ) .. I am not getting alerts ( i am not using SystemUpdate() ) .. but when I update the item manually i get the update alert .. strange..

    • January 6, 2009 at 6:45 pm
      Permalink

      I don’t suppose you got this working with the Author field? It won’t work for me…

    • January 6, 2009 at 11:45 pm
      Permalink

      Author field has wider problems. I have seen Author field problems also when exporting/importing sites content. I don’t think this problem lies here. It must be something more serious.

    • November 5, 2009 at 11:04 am
      Permalink

      Thank u so much.

      Valueable information. what about the user if we don’t want to change on updation?

      Kuldeep Kadyan

    • November 16, 2009 at 6:55 am
      Permalink

      Hi,

      After reading above article i am confused.When ever we update the list item, Is it require to call ListItem.Update() as well as List.Update()?

      I think for update/delete/insert we do need to call ListItem.Update. For Insert/delete/update field(coulmn) we need to call List.Update().

      Please let me know is above statment is correct or not?

      Thanks,

      Samit

    • November 16, 2009 at 12:15 pm
      Permalink

      Hi, Samit!

      You don’t need List.Update() as you don’t change properties of list.

    • November 30, 2009 at 8:19 am
      Permalink

      Thanks for this article, it has been very useful.

    • April 5, 2011 at 11:23 am
      Permalink

      this is code to delete item on gridview sharepoint

      protected void btDelete_Click(object sender, EventArgs e)

      {

      SPWeb web = SPContext.Current.Web;

      SPList list = web.Lists[“ListEmployee”];

      foreach (GridViewRow row in GridView1.Rows)

      {

      CheckBox checkstatus = (CheckBox)row.FindControl(“checkItem”);

      if ( checkstatus.Checked == true )

      {

      TextBox txtID = new TextBox();

      txtID.Text = GridView1.DataKeys[row.RowIndex].Value.ToString();

      list.GetItemById(Convert.ToInt32(txtID.Text)).Delete();

      list.Update();

      }

      }

      GridView1.EditIndex = -1;

      BindtoGridview();

      }

    • July 30, 2011 at 12:52 am
      Permalink

      Can somebody pelase tell me how to do this with the Client OM

    • February 22, 2012 at 5:04 am
      Permalink

      Hi Graham,

      I don’t think this is possible using Client OM.

      In Client OM, for ListItem, only Update() is present to update the item and it always increases version if versioning is enabled in the list.

    • July 23, 2014 at 4:03 am
      Permalink

      Hi Graham,

      Thank you very much, this is solving my problem on SharePoint 2010 too.

    Leave a Reply

    Your email address will not be published. Required fields are marked *