SharePoint DocumentSet Event Receiver ItemAdded isn't firing

1.8k views Asked by At

I've programatically created ContentType based on document set and want to attach event receiver to it. Looks something like this:

SPEventReceiverDefinition eventReceiverDefinition =   TestDocumentSet.EventReceivers.Add();
        eventReceiverDefinition.Class = "DocSetsTesting.EventReceivers.DocSetReceiver.DocSetReceiver"; // String
        eventReceiverDefinition.Assembly = Assembly.GetExecutingAssembly().FullName; // String
        eventReceiverDefinition.Type = SPEventReceiverType.ItemAdded; // SPEventReceiverType
        eventReceiverDefinition.Data = "XML"; // Arbitrary input data (String)
        eventReceiverDefinition.Update();

When I do this for ItemAdding event, handler works. But it won't work for ItemAdded. I do all this stuff because I want to make files with specific content types hidden, so I want them not to be showed in the Document Set Contents Web Part. Is it possible at all? And may be there is a simpler way to do this? Thanks a lot.

1

There are 1 answers

1
Rikard Uppström On

It seems to me that you forgot to add ContentType.Update(true). Also, remember that ItemAdded is an asynchronous event and doesn't run in the w3wp-process. To debug it you need to attach to the owstimer.exe process.