1

I have created event receiver, and now i want to add the event whenever the new document is added to shared document library. Which event should i write?(ItemAdded or ItemUpdated)

Thanks.

Element.xml

    <?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Receivers ListUrl="Shared Documents">
    <Receiver>
      <Name>SharedDocPermissionItemAdded</Name>
      <Type>ItemAdded</Type>
      <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
       <Class>SharedDocPermssionForNewDoc_ER.SharedDocPermission.SharedDocPermission</Class>
  <SequenceNumber>10000</SequenceNumber>
</Receiver>

  • New document should be ItemAdded. ItemUpdated will only fire on existing documents. – Christoffer Mar 5 '15 at 12:04
  • On ItemAdded is not working.. Before i have tried ItemUpdated,it was working.. But now that is also not working – Ishani Mar 5 '15 at 12:05
  • Have you tried ItemAdding? You should add what you are trying to accomplish in your question to get a more clear answer. – Christoffer Mar 5 '15 at 12:08
  • My question is clear.. i just want to add a new document and on adding a new document, event should be fire. But ItemAdded is not working – Ishani Mar 5 '15 at 12:12
  • Well, i think you just answered your own question. You are saying adding a new document, and then the event should be ItemAdding that fires before the document is added, while ItemAdded fires afterwards when the document already has been uploaded. – Christoffer Mar 5 '15 at 12:17
1

ItemAdded will fire AFTER the document is ADDED/UPLOADED.

ItemUpdating will fire BEFORE the document is UPDATED/EDITED/CHANGED.

In your case it sounds like you need ItemAdded.

EDIT:

You have since added your event receiver's elements.xml. I can see you're missing the closing tags at the end: </Receivers></Elements>

You also say you initially tried ItemUpdating, which fired correctly. Then you tried ItemAdded and it didn't fire. I think you tried to change the originally created event receiver and didn't change it properly.

So you should create a fresh new ItemAdded event receiver and DO NOT try changing it to ItemUpdating or anything else. If you want a different event receiver, it is best to create a new one if you are not 100% sure on how to change an existing one.

If this still does not fire then share both the elements.xml and the event receiver code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.