What is the difference between Item.Update() and Item.System.update()?
Venkata Polepalli
When writing code for a SharePoint List, and updating the ListItem, you have seen two methods named Update() and SystemUpdate(). Both methods update the ListItem data in backend database for your site in SharePoint but there is a little difference between them.When you call the ListItem.Update() method at that item, it updates the item data as well as the Modified and Modified By columns also. When you call the ListItem.SystemUpdate() method at that item, it updates only the item data and does not update the Modified and Modified By columns for that Item.
Item.update method create a new version of item and update some other field also in a list like modified,modifiedby,created,,createdby. While item.systemupdate() not modify these fields.
Item.Update()Updates the item in the database.Updates the “Modified” and “Modified by” values.Creates a new versionItem.Systemupdate()Updates the item in the database.No changes in the “Modified” and “Modified By” fields.No new version.Triggers the item events.
In case of SharePoint ListItem,if we want to update some changes in the list item like "ModifiedBy","ModifiedOn" and even "Item Version", then the best solution is to use "Item.Update()" method. But if we don't want such changes in the list,then it is fine to use "Item.System.Update()" method instead of using "Item.Update()" method.
Generally when we try to add/edit a SPListItem using SharePoint Object Model? Yes I know it! Almost everybody have common answer to this (which is similar to what is provided below).
SPListItem item = SPList.Item.Add();
Item[“Col1”] = “Value for Col1”;
Item[“Col2”] = “Value for Col2”;
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.
Conclusion: item. Update () will updates what we are updating the List Items as well as “ModifiedBy”, “ModifiedOn” and “ItemVersion” If Version is enabled.
iem.Systemupdate() will updates what we are updating the list items only, it will not update the “ModifiedBy”, “ModifiedOn” and “ItemVersion”.