Tuesday, April 29, 2014

Only one Alert Handler allowed in Sharepoint

As you know, alerts in SharePoint are triggered when something happens on a file or on a library. An email (or an SMS) is sent for each modification. This can be customized by code by implementing an Alert Handler. Basically talking, instead of the email to be sent, the alert handler calls your code and you are responsible for sending the email (or doing whatever you want).
Here there are several problems. First is that if your alert handler raises an exception then the alert is not sent... nothing happens. So if your application does not behave OK then uses will not receive alerts. The second problem is that the email should be sent by the alert, and optionally if you want to send the alert instead, then no alert should be sent (since you will do it).
To overcome these two cases it's just enough to modify the way IAlertNotificationHandler::OnNotification behaves... if you return true then the original alert should be sent (like if the alert handler was not installed) and if you return false then it means "do not send the alert" and you do whatever you want (even sending your own alert). This is good since sometimes you only want to modify some alerts and not all them.

The third big problem is that you cannot register two alert handler at the same time. Only one alert handler can exist. This is a big problem since suppose that an alert handler is part of a third party product. It means that two third party products that use alert handlers will be incompatible each other. This is because to install the alert handler you must modify an internal XML document and only one entry can be used.

Analyzing this it seems like if when MS was thinking in the alert handler, it was only thinking in corporate programmers (that is, programmers that work directly for a company like a bank) but not in software companies.. like if they are interested in providing APIs to direct customers of MS rather than on independent software vendors.

In my opinion the alert handler should behave like an event receiver where the receiver can cancel the request, and you can have more than one event receiver at the same time.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home