My SharePoint Blog

Blogs On SharePoint Technologies


Search Site


My SharePoint Blog recommends any of the following books...


Recent comments

Tags

None

    Categories


    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2010

    Mange Event Handlers (Setup and Usage)

    This post documents the "Manage Event Handlers" (MEH) project from Codeplex.  The MEH tool allows you rapid deployment of event handlers.  Additionally you can assign the handler to any Site, List, or Content Type.  Note: this works for WSS 3.0 and MOSS 2007.

    The .wsp file is located here:

    http://www.codeplex.com/SPSCustomAdmin/Release/ProjectReleases.aspx?ReleaseId=3024

    To install the MEH tool from command line:

    stsadm -o addsolution -filename MOSS.CustomAdminPages.EventHandlers.Deploy.wsp

    stsadm -o execadmsvcjobs

    stsadm -o deploysolution -name MOSS.CustomAdminPages.EventHandlers.Deploy.wsp -local -force -allowGacDeployment -allowCasPolicies 

    stsadm -o execadmsvcjobs

    stsadm -o activatefeature -name ManageEventHandlers -url http://foobar.com

    stsadm -o execadmsvcjobs 

     

    Now you should see your MEH tool in the Site Setting Page:


     
     
      
     
    Now build the event handler as you normally would and drop the compiled dll in the GAC.  
     
    After the assembly is in the GAC, you can now add it to your SharePoint site and assign it to a Site, List, or Content Type using the "Add" page of the MEH tool:
     
     

     

    You can assign the same event handler to many different Site, Lists, or Content types.  You need only click "Add" and set the properties!! 

    Awesome! 

    Show the AfterProperties snippet:

    protected void showAfterProperties(SPItemEventProperties properties)

            { 

                using (SPWeb web = properties.OpenWeb())

                {

                    String strTemp = "";  

                    /*get the current list*/

                    SPList list = web.Lists[properties.ListId];

                    string columnName = "";

                    foreach (SPField fld in list.Fields)

                    {

                        columnName = fld.InternalName;


                        if (properties.AfterProperties[columnName] != null)

                            strTemp += "\n" + columnName + ": " + properties.AfterProperties[columnName].ToString();

                    }

                    properties.ErrorMessage += strTemp;

                    properties.Cancel = true;

                }

            } 

     

    Additional Notes:

    http://jpy-tech.com/post/2009/02/05/Sharepoint-Unique-Column-(PK)-Using-event-handler.aspx 

    http://www.sharepointblogs.com/toth/archive/2008/06/06/workarounds-for-itemadding-itemadded-event-handlers.aspx

    http://www.iterasi.net/openviewer.aspx?sqrlitid=-lt435um10as0obb4eq48q

     


    Posted by Kevin on Thursday, June 04, 2009 2:36 PM
    Permalink | Comments (0) | Post RSSRSS comment feed

    Comments