SharePoint 2010 Save Conflict Error on Event Receivers

Recently I tried to modify all Infopath list right after they were uploaded to the library.
I went for ItemAdded event receiver to be sure all metadata etc is there. Then I hit this error:

Save Conflict. Your changes conflict with those made concurrently by another user. If you want your changes to be applied, click Back in your Web browser, refresh the page, and resubmit your changes.0x81020037

Of course ItemAdded event is asynchronous so there is a big chance SharePoint, workflow or other event receiver was still changing something and I was caught up in the middle of this or my changes executed other event receivers like ItemUpdating.

So to fix it there are t hings that need to be done.

1) Make things synchronous.
In my case asynchronous event has to be made synchronous and fortunately SharePoint 2010 introduce Synchronization (both in CAML and code)

So simple



eventReceiver.Synchronization =

will solve it.

2) Disable event firing
To avoid other event receivers to fire we need to change EventFiringEnabled flag. You can do it in various different ways but I particularly like this approach:

Leave a Reply

Your email address will not be published. Required fields are marked *