Update vs SystemUpdate

Update vs SystemUpdate
4 votes, 3.25 avg. rating (70% score)

Introduction

In this post I will explain differences between SystemUpdate and Update.
It’s pretty much clear that we can upate list data programatically from SharePoint object model. Also, there are other ways of updating list data
from client side with sharepoint exposed client api(client object model, ecma script or list webservices). We will see further what is difference


Update vs SystemUpdate

using (SPSite siteObj = new SPSite("http://mySiteCollection/mySite"))
         {
            using (SPWeb webObj = siteObj.OpenWeb())
            {
               SPList empListObj = web.GetList("/lists/EmpList/");
	       SPListItem empItem = empListObj.Items.Add();
	        empItem["Title"] = "Emp1";
		empItem["Department"] = "Finance";
		empItem.Update();
		//empItem.SystemUpdate();
		//empItem.SystemUpdate(true);
		//empItem.SystemUpdate(false);

	     }
	   }

Update

In the above code, Line 9 empItem.Update() will update the “EmpList” data. This will also update the built in columns “Modified” and “Modified By”.

SystemUpdate

If we are using Line 10 empItem.SystemUpdate(); this will update the “EmpList” data but not the built in columns “Modified” and “Modified By”.
If we are using Line 11 empItem.SystemUpdate(true);this will update the “EmpList” data but not the built in columns “Modified” and “Modified By”. But it will increment the item version
If we are using Line 12 empItem.SystemUpdate(false);this will update the “EmpList” data but not the built in columns “Modified” and “Modified By”. Also, does not increment the item verision

SystemUpdate will trigger all the list events if any and also the changes can be observed in Audit logs. Only alerts will not be triggered that are configured on the list.

Note:
If we are using SharePoint model, we are flexible to use any of the methods as per our requirement.
But, if we are using client object model only Update method will be available, SystemUpdate method will not be available. Its obvious that SystemUpdate method is not available because, clients are updating the database data and server should be aware of this(though logs are still updated).
I think that is good reason why client object model does not expose SystemUpdate method.

Conclusion

Hope you understand the differences between Update and SystemUpdate. Happy coding :)

References

Client Object Model ListItem methods
SharePoint Object Model SPListItem methods

March 31, 2012 В· Adi В· No Comments
Tags: , , , ,  В· Posted in: Client Object Model, Sharepoint 2010

Leave a Reply

What is 3 + 9 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)