Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am trying to create and install an IAlertUpdateHandler interface to prevent SharePoint from sending emails on alert creation and am having trouble getting it to fire. By contrast, I have had no problem implementing and installing IAlertNotifyHandler.

As per the suggestion by TheVillageIdiot I saw at Implementation of IAlertUpdateHandler I have implemented the interface as follows:

namespace MyCompany.MyAlertHandler 
{
    public class UpdateHandler : IAlertUpdateHandler
    {
        static public SPDiagnosticsCategory diagnosticCategory = new SPDiagnosticsCategory("***** LOGGED BY KJ *****", TraceSeverity.High, EventSeverity.Error);

        const bool SUPPRESSING_EMAIL = true;

        public bool PreUpdate(SPAlert a, SPWeb web, bool newAlert, string properties)
        {
            SPDiagnosticsService.Local.WriteTrace(0, diagnosticCategory, TraceSeverity.Unexpected, "entering PreUpdate");

            if (web.Url.ToLower().Contains("/kjtestlist") // only affect alerts on kjtestlist list
                && SUPPRESSING_EMAIL
                && !a.Properties.ContainsKey("CustomUpdate"))
            {
                // add a property to identify this update
                a.Properties.Add("CustomUpdate", ""); //can be called anything :)
                a.Update(false);
                // return false to ignore the update sent by the UI
                return false;
            }
            else
            {
                return true;
            }
        }

        public bool PostUpdate(SPAlert a, SPWeb web, bool newAlert, string properties)
        {
            SPDiagnosticsService.Local.WriteTrace(0, diagnosticCategory, TraceSeverity.Unexpected, "entering PostUpdate");

            return true;
        }
    }

}

I have also created a variant of AlertTemplates.xml called CustomAlertTemplates.xml and added these lines to each of the templates I modified when I got the IAlertNotifyHandler interface working (and then run the needed stsadm command to have Sharepoint make use of this file).

<UpdateHandlerAssembly>MyCompany.MyAlertHandler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=28fe07cbb1c88da4</UpdateHandlerAssembly>              
<UpdateHandlerClassName>MyCompany.MyAlertHandler.UpdateHandler</UpdateHandlerClassName>

And finally, I have set up VS to install the dll in the GAC (and confirmed it is going there), and I have reset iis (as well as the timer service).

Having done all these things, however, I still have no evidence that this code is being executed... i.e. nothing shows up in the log (despite those logging statements therein). And I get the alert creation emails as normal, though this code is supposed to suppress them.

I have tried to set breakpoints, and attached to both the timer service and to w3wp, but again I never seem to enter the code.

So I was wondering if any of you have successfully implemented and installed this interface? Am I missing something?

Thanks so much!

K. Jones

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.