Difference between ListItem.Update() and ListItem.SystemUpdate()
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
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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| 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
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.
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.
Comments
Post a Comment