Remote Event Receiver in SharePoint (2013 and
more up to date), we go over two methods that are available default when we
create a remote event receiver *.svc file (generated by system). These are --
- ProcessEvent()
- ProcessOneWayEvent()
Both the methods are always confusing as for
their usage. There is very limited information available on the web with
respect to these methods. In this way, here is the essential difference between
them by which one can get the unmistakable fundamental thought of them both,
subsequently, choosing the required one between them to write their business
codes.
We should comprehend the sorts of events fired in event receivers. There are for the most part 2 types event fired on any operations on list or libraries - "before events" and "after events".
We should comprehend the sorts of events fired in event receivers. There are for the most part 2 types event fired on any operations on list or libraries - "before events" and "after events".
Now all events finishing with "- ing" are named as “Before events”, while every one of the events
finishing with "- ed" are
called as “After events”.
Below are the 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
|
Now, when we are aware of After and Before
events, it becomes easy to understand the basic difference between these
methods.
ProcessEvent()
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 excel (*.xlsx) 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 *.xlsx 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.
Prepare4Test APICS CPIM-ECO PDF is designed with the latest CPIM-ECO exam material. All questions are planned and verified by APICS certified experts.
ReplyDelete