Saturday, July 27, 2013

Making SharePoint event receiver event Asynchronous to Synchronous to avoid save conflict error


There are some scenario in Event Receiver when sometimes we get Save Conflict Error while uploading a single document to document library 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:
1- Open Elements.xml file of Event Receiver and add below section inside Receiver tag....

<Synchronization>Synchronous</Synchronization>

See here my complete Element.xml file...

<?xmlversion="1.0"encoding="utf-8"?>
<Elementsxmlns="http://schemas.microsoft.com/sharepoint/">
<ReceiversListTemplateId="100">
<Receiver>
<Name>EventReceiver1ItemAdded</Name>
<Type>ItemAdded</Type>
<Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
<Class>AddItemEventReceiver.EventReceiver1.EventReceiver1</Class>
<SequenceNumber>10000</SequenceNumber>
<Synchronization>Synchronous</Synchronization>
</Receiver>
</Receivers>
</Elements>


Reference:

No comments:

Post a Comment

SharePoint Deployment Error : The specified path, file name, or both are too long.

Hi, Sometimes we get surprised with below error while deploying wsp file... Solution : To overcome with this issue, we just ne...