Difference Between Process Event() And Process One Way Event() In Event Receiver

Whenever we work with Event Receiver or Remote Event Receiver in SharePoint, we come across two common methods that are automatically created when we add an event receiver *.svc file. These methods are -

  • ProcessEvent()
  • ProcessOneWayEvent()

Both the methods are always confusing with respect to their usage. There is very limited information available on the web regarding these two methods. So, here is the basic difference between them by which one can get the clear basic idea of them both, hence, selecting the required one between them to write their business logic codes.

Before moving directly to the difference, let's understand the types of events fired in event receivers. There are mostly 2 types of events fired on any list operations, list item operations - "before event" and "after event".

All events ending with “-ing” are termed as Before events, while all the events ending with “-ed” are called as After events.

Examples for Before and After Events -

Before Events After Events
ListAdding ListAdded
ListDeleting ListDeleted
FieldAdding FieldAdded
FieldDeleting FieldDeleted
FieldUpdating FieldUpdated
ItemAdding ItemAdded
ItemUpdating ItemUpdated
ItemDeleting ItemDeleted
ItemCheckingOut ItemCheckedOut
ItemCheckingIn ItemCheckedIn
ItemUnCheckingOut ItemUnCheckedOut
ItemAttachmentAdding ItemAttachmentAdded
ItemAttachmentDeleting ItemAttachmentDeleted
ItemFileMoving ItemFileMoved
ItemVersionDeleting ItemVersionDeleted

There are other events also like AppInstalling, AppInstalled, AppUninstalling, and AppUnistalled likewise.

Now, when we are aware of After and Before events, it becomes easy to understand the basic difference between these methods.

ProcessEvent()

  • It handles "Before" events and returns an object to SharePoint that reports on whether it should cancel the current process or terminate it.

  • If you want to use any of the “-ing” events, then write your codes in ProcessEvent().

  • Example: If you wish that there should be only word (*.docx) file uploaded in particular document library, this can be done using the file type extension setting in SharePoint Server Administration.

    But, what about SharePoint Online?

    So, here you have to create remote event receiver and in that, you can use the event of ItemAdding and check whether the uploaded document is of *.docx type or not. If not, then you can cancel the uploading event. This cancelled event will return back to SharePoint by this ProcessEvent() as this is 2 way method. This can be achieved by writing your logic code in ProcessEvent().

ProcessOneWayEvent()

  • It handles "After" events. It runs asynchronously and does not return anything to SharePoint.

  • If you are using any code which is to be run after the “-ed” event, then write your codes in ProcessOneWayEvent().

  • Example: Let's say, you want to duplicate the document uploaded in document library to any other document library, in that case, you can use ItemAdded. This does not require any 2 way communications between SharePoint, so you can use ProcessOneWayEvent() for this kind of requirement.

Hyper Cloud 365 Software Solution
Hyper Cloud 365 Software solution is a development and IT Consulting company.