SharePoint event receivers: Making Asynchronous event Synchronous to avoid save conflict error

Typical scenario would be an ItemAdded event is activated for a document library. When uploading a single document from UI, the edit properties page appears, we update the properties and save the changes, there is a possibility to get a Save conflict error. This is because ItemAdded is an Asynchronous event.

To avoid this error the ItemAdded event can be made Synchronous by doing the following:

<Elements xmlns="https://schemas.microsoft.com/sharepoint/">
  <Receivers ListUrl="ListName">
    <Receiver>
        <Name>EventReceiver1ItemAdded</Name>
        <Type>ItemAdded</Type>
        <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
        <Class>EventReceiverProject1.EventReceiver1.EventReceiver1</Class>
        <SequenceNumber>1000</SequenceNumber>
      <Synchronization>Synchronous</Synchronization>
     </Receiver>
</Receivers>
</Elements>

In the highlighted text:

  • ListURL contains the list name for which the event receiver needs to be activated. It can also have ListTemplateId, that would mean that the event receiver is activated for all the lists/libraries created with the template ID.
  • Synchronization node has the value "Synchronous", which will make the ItemAdded event Synchronous.