Aside

Difference Between List.Update() and List.SystemUpdate()

Difference Between List.Update() and List.SystemUpdate()

Updates the database with changes that are made to the list item without changing the Modified or Modified By fields.

Overload List


 

Name

Description

 

SystemUpdate()

Updates the database with changes made to the list item without changing the Modified or Modified By fields.

 

SystemUpdate(Boolean)

Updates the database with changes that are made to the list item without changing the Modified or Modified By fields, or optionally, the item version.

 

What is the general approach we follow when we try to add / edit a SPListItem using the SharePoint object model? Yes I know it! Almost everybody will have a common answer to this (which is something similar to what is provided below).

SPListItem item = SPList.Items.Add();

item[“Column1”] = “value for column 1”;

item[“Column2”] = “value for column 2”;

item.Update();

The last line in the code above “item.Update()” does the final task of updating all the assigned value for that specific item within the SPList.

But is this the only way to update an item? No, we can also update the same item using

item.SystemUpdate();

 

Then what is the difference between the two?

With item.Update(), we update the changes that are made to the list item. Is that all what it does? No, internally it also updates the “ModifiedBy” and “ModifiedOn” fields as per the current logged in user and current server time. Optionally it also updates the version of the item if the Versioning option is turned on for that specific list.

So, at any point if we wish not to update these extra things i.e. the “ModifiedOn”, “ModifiedBy” and the “Item Version”, then the solution for it is to use item.SystemUpdate() instead of item.Update(). This will help you in updating only those fields which are specified within your code blocks.

Advertisements

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 )

Google+ photo

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

Connecting to %s