Denis Gursky
Denis Gursky

Reputation: 21

SharePoint DocumentSet Event Receiver ItemAdded isn't firing

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.

Upvotes: 2

Views: 1831

Answers (1)

Rikard Uppström
Rikard Uppström

Reputation: 1413

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.

Upvotes: 1

Related Questions