SharePoint Item Event Receivers and Site Creation

Posted by Michael Edwards on Stack Overflow See other posts from Stack Overflow or by Michael Edwards
Published on 2009-09-30T15:00:18Z Indexed on 2010/04/06 22:03 UTC
Read the original article Hit count: 292

Filed under:
|
|

I have created an Item Event Receiver for a document library and I have test that the logic works correctly and it all does. The next thing I wanted to do is automatically create the list when a site is created so I added the list to the ONET.xml file for the site:

<Lists>
  <List Title="Documents" Description="Documents " url="MyDocumentLibrary" Type="10002" FeatureId="CFD8504D-70EB-4ba2-9CCB-52E38DB39E60" QuickLaunchUrl="Docs/AllItems.aspx" />
</Lists>

And I ensure that the feature for this list is also activated be adding the feature to the

<WebFeatures>
  <Feature ID="CFD8504D-70EB-4ba2-9CCB-52E38DB39E60" />
</WebFeatures>

The problem occurs after I create the site, when I add a document to the list the Item Event Receiver does not run. However if I manually for to the web site features and deactivate and then reactivate the feature the Item Event Receiver does run. It seems that when creating a list through the ONET.xml and activating the feature it does not bind the Item Event Receiver to the list. What is the work around for this? Is this a bug?

© Stack Overflow or respective owner

Related posts about sharepoint

Related posts about features