SharePoint 2013 SPListItem method Update SystemUpdate and UpdateOverwriteVersion

SharePoint 2013 SPListItem method Update SystemUpdate and UpdateOverwriteVersion

In this post we will discuss about SharePoint 2013 SPListItem methods like Update(), SystemUpdate(), SystemUpdate(Boolean) and UpdateOverwriteVersion().


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

Also, read:
Steps to freeze header row for the title in SharePoint 2013 List view or document Library on scrolling using jQuery

SharePoint 2013 List View Filtering with Query String

SharePoint 2013 Metadata Navigation Settings in List and Libray

SPListItem.Update() Method:
This is a very common method which we uses while updating a list item using server object model code, it updates the database whatever changes made to the list item.

SPListItem.SystemUpdate():
This method updates the list item without changing the modified date and modified by field. This will modify those fields which are provided to change.

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

SharePoint 2013 SPListItem method Update SystemUpdate and UpdateOverwriteVersion
SharePoint 2013 SPListItem method Update SystemUpdate and UpdateOverwriteVersion

Then I have wrote 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 do not changed like below:

SharePoint 2013 SPListItem method Update SystemUpdate and UpdateOverwriteVersion

SharePoint 2013 SPListItem method Update SystemUpdate and UpdateOverwriteVersionSPListItem.SystemUpdate(Boolean):
This method will be helpful in case you list or library has versioning enabled. If you pass False then it will not create any version, but it works 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 2016 SPListItem method Update SystemUpdate and UpdateOverwriteVersion
SharePoint 2016 SPListItem method Update SystemUpdate and UpdateOverwriteVersion

Hope this will be helpful.


You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →