I have an item receiver that implements ItemUpdated()
to process an item after it has been uploaded to a document library. Everything works fine if I add documents to the default "Shared Documents" library - when a new document is added, ItemUpdated()
is triggered normally. However, if I create a new document library in the same site collection, ItemUpdated()
is not triggered when I upload a new document to it. But when I upload another version, or rename the document etc., ItemUpdated()
is triggered normally - it's just not triggered on item upload. Typical example:
- I upload 'doc1' to document library -
ItemUpdated()
doesn't execute (but it does execute if the document library is "Shared Documents"); - I upload another version of 'doc1' -
ItemUpdated()
executes as expected; - I rename 'doc1' -
ItemUpdated()
executes as expected.
I was lead to believe that the order of events when adding a document is normally:
adding - added - updating - updated
So why is my ItemUpdated()
not getting triggered for libraries other than "Shared Documents"? Is there some setting that may be causing this?
Note that for various reasons, I cannot do the processing inside ItemAdded()
.
Elements.xml:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Receivers ListTemplateId="101">
<Receiver>
<Name>MyEventReceiverItemUpdated</Name>
<Type>ItemUpdated</Type>
<Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
<Class>MyProject.MyEventReceiver.MyEventReceiver</Class>
<SequenceNumber>1000</SequenceNumber>
</Receiver>
</Receivers>
</Elements>
Code:
public class MyEventReceiver : SPItemEventReceiver
{
// On document upload, this method is only entered if I upload to "Shared Documents"
public override void ItemUpdated(SPItemEventProperties properties)
{
base.ItemUpdated(properties); // doesn't get called either
MyMethod(properties);
}
}