Frustrations with Check in/Check out event handlers
July 31st, 2008
I wanted to write up some notes about a recent frustration I’ve had with Sharepoint 2007 events. I was asked to develop a (fairly simple) method of replicating the check in/check out event between a master Sharepoint site and several replica sites (Where the Sharepoint data has been replicated using my company’s own software). I’ve implemented a fairly simple system involving an event handler installed on the replica machines and a web service on the master. The concept is straightforward enough, and ensures that users are unable to check out documents that are already checked out elsewhere and that checked in data is up to date (as well as handling version numbers and undo check-out requests!).
The check in/check out system is not the focus of this blog entry. The frustration I spoke of earlier involves the SPItemEventProperties ErrorMessage property which can be set when you override the synchronous/asynchronous event functions.
So I have a class like this:
| … public class CheckingEvent : SPItemEventReceiver {… public override void ItemCheckingOut(SPItemEventProperties properties) { // business logic …… // if something bad happens{… properties.Cancel = true; ;} |
..Please excuse lack of indenting, I am still fighting with WordPress to be able to display code in a presentable fashion..
Updating the ErrorMessage property like this would normally display the error message within the browser…nice. Except in this case, checking out, it doesn’t work due to a bug in SharePoint! Instead we are treated to a message box appearing proudly displaying the words “Attempted to read or write protected memory“. Smashing..not..
At the moment, even with all the current service packs installed I can’t get the error message to appear correctly.
Currently the ONLY workaround I have found is to implement:
| properties.Status = SPEventReceiverStatus.CancelNoError; |
..instead. Which will display the standard error message. “You may not have permission to check out the document or it is already checked out or locked for editing by another user.” which isn’t great, but it at least makes my solution usable until Microsoft fix the bug.
Tags: event handlers, Sharepoint
Posted in
Sharepoint |
1 Comment »
May 11th, 2009 at 5:53 am
Interesting a post, thanks! I shall read Now yours blog