SPListItem.Update() - The file has been modified by SHAREPOINT\system
Sometimes it is necessary to have multiple solutions like event handlers, timer jobs, workflows, etc on SharePoint list items, which might work concurrently.
For example I’m working on a SharePoint project in which I create publishing pages using a PowerShell script, based on a XML file like below:
In the PS script I create a publishing page, set the properties as specified in the XML file, and then perform a $item.Update()
$pWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
$page = $pWeb.AddPublishingPage($PageUrl,$Layout)
$item = $page.ListItem
$item["Title"] = $PageTitle;
$item["Page Content"] = $PageContent;
I also had an Event Receiver bind to the same pages library, which will update a field in the content type in ItemAdded and ItemUpdated events.
public override void ItemAdded(SPItemEventProperties properties)
using (SPWeb web = properties.OpenWeb())
Guid pagesLibraryId = Microsoft.SharePoint.Publishing.PublishingWeb.GetPagesListId(web);
SPList pagesLibrary = web.Lists[pagesLibraryId];
SPListItem item = properties.ListItem;
item[NEWSCLASSIFICATIONFIELD] = NEWS_RELEASE;
catch (Exception e)
But when I run the PS script I always get the error: Exception calling "Update" The file has been modified by SHAREPOINT\system.
When the page is created in PS, event receiver also fires and updates the list item. Then when PS try to update the lists item SharePoint throws an error since it is trying to perform an operation on a SPListItem that has been modified.
Instead of using SPListItem.Update() method, I used SPListItem.SystemUpdate(false) method in both PowerShell script and in the event receiver.
PowerShell script: $item.SystemUpdate($false)
Event receiver: item.SystemUpdate(false);
SPListItem.SystemUpdate() method updates the database with changes made to the list item without changing the Modified or Modified By fields. By passing false as the parameter, SPListItem.SystemUpdate(bool incrementListItemVersion) method will not even increment the item version.
------------ Update -------------
By default SharePoint event receiver ItemAdded executes asynchronously. We can make it synchronous by adding Synchronization tag in the event receiver Elemeny.xml file. This will also fix the issue mentioned in above case.