Wednesday, December 17, 2014

Item Update vs SystemUpdate

Recently there was a need to update documents/ list items without creating new version and updating 'Modified' and 'Modified by' values.  Lists and Libraries were having event receivers or workflows. There are couple of options to update SPListItem and need to understand the differences between them. 
Update()
·        Updates the item in the database.
·        Updates the 'Modified' and 'Modified by' values.
·        Creates a new version
Systemupdate()
·        Updates the item in the database.
·        No changes in the 'Modified' and 'Modified by' values.
·        No new version.
·        Triggers the item events.
Systemupdate(true)
·        Same as Systemupdate() and it increments item version.
·        Using SystemUpdate(false) is same as SystemUpdate().
UpdateOverwriteVersion()
·        Updates the item but does not create a new version.
·        Updates the  'Modified' and 'Modified by' values.
you could set EventFiringEnabled = false to disable the triggering of events (workflows). Set EventFiringEnabled = true after item update to enable the events again.