SharePoint 2013 SPListItem methods: Update(), SystemUpdate() and UpdateOverwriteVersion()

This SharePoint tutorial we will discuss about SharePoint SPListItem methods like Update(), SystemUpdate(), SystemUpdate(Boolean) and UpdateOverwriteVersion().

These are the methods that we can use with the SharePoint server object model code in SharePoint 2010/2013/2016 etc, but we can not use it in SharePoint Online.

SharePoint 2013 provides various methods to update list items while working with the server object model. Let us discuss those methods below:

SPListItem.Update() Method

This is a very common method which we use while updating a list item using the SharePoint server object model code, it updates the database whatever changes made to the list item.

SPListItem.SystemUpdate()

This method updates the SharePoint list item without changing the modified date and modified by field in SharePoint. This will modify those fields which are provided to change.

Here I have a SharePoint list and I have added the item on October 10th, so you can see the Created and Modified on October 10th like below:

SharePoint SPListItem.SystemUpdate()

Then I have written a server-side code to update the Title by using the SystemUpdate() method. The code like below:

protected void btnUpdate_Click(object sender, EventArgs e)
{
using (SPSite site = new SPSite("http://win-pfcp2dgt8di/sites/EnjoySharePoint"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["MyTestList"];
SPListItem item = list.Items[0];
item["Title"] = "Testing through UpdateOverwriteVersion method Modify Date";
item.SystemUpdate();
}
}
}

Now when you will see the list the Title is changed but the Modified date does not change like below:

SharePoint SPListItem.UpdateOverwriteVersion()

This method will be helpful in case your list or library has versioning enabled. If you pass false then it will not create any version, but it works the same as SystemUpdate.

SPListItem.UpdateOverwriteVersion()

It updates the modified date field. In the below code, it will update the modified date field as well as the Title column like below:

protected void btnUpdate_Click(object sender, EventArgs e)
{
using (SPSite site = new SPSite("http://win-pfcp2dgt8di/sites/EnjoySharePoint"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["MyTestList"];
SPListItem item = list.Items[0];
item["Title"] = "Testing through UpdateOverwriteVersion method Modify Date";
item["Modified"] = DateTime.Now.AddDays(-3);
item.UpdateOverwriteVersion();
}
}
}

Once you execute the code, then you can see the title as well as the modified date like below:

SharePoint SPListItem.SystemUpdate()

You may like following SharePoint tutorials:

This SharePoint tutorial, we learned how to use SPListItem.UpdateOverwriteVersion(), SPListItem.Update() Method, SPListItem.SystemUpdate() methods in SharePoint 2013/2016/2010 while working with the SharePoint server object model code.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>