My questions are:

  1. Is it always necessary to call the parent (base) event receiver, assuming the event is to proceed to completion? I've recently learned that the base version cannot be called in ItemUpdating/Adding if the event is to be cancelled.

  2. Should the aforementioned call be before or after the custom code?

  3. Is it safe to exit the method (i.e. return;) after setting the properties cancellation to true?

I obviously have no idea what the base version does. I would imagine it does everything my code doesn't (add, update, etc.). Based on that, I would assume it should go at the end of my custom actions. Although I would prefer not to base my work on an assumption.

1 Answer 1

  1. There is nothing significant in those base classes apart from throwing ArgumentNullException when properties is null. So there is no harm in calling it, but there is no harm if you miss it.

  2. If do call it, you should call it before your code

Instead of setting Cancel Property to true, you should set an appropriate value for Status property. According to the documentation, the Cancel property is deprecated and should not be used.

You should NOT call the base class methods after you set the Status property as it could be overridden by the base classes.

My understanding is that the actual code to add/update/delete items and documents is elsewhere, not in these bases classes. The event receiver base classes are provided so that you have an opportunity to plug in your code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.