1

I am trying to develop an Event Receiver for a document library titled Temporary. I have modified the Elements.xml document to look like this:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Receivers ListUrl="Temporary/Forms">
    <Receiver>
      <Name>CleanUpTemporaryItemAdded</Name>
      <Type>ItemAdded</Type>
      <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
      <Class>MeritSolutions.MAXLife.SP.CleanUpTemporary.CleanUpTemporary</Class>
      <SequenceNumber>10000</SequenceNumber>
    </Receiver>
  </Receivers>
</Elements>

When I run the code to debug, it doesn't work - SharePoint Manager 2010 doesn't show that there are any receivers attached to the Temporary document library. I know that the key is in the ListUrl="Temporary/Forms" line, but I can't get it to work. I tried with "Temporary", "/Temporary", "Temporary/Forms" and "/Temporary/Forms", but nothing helped. My document library is hidden; does that have to do anything with it maybe? My site is the site collection root site, i.e. http://spserver/sites/site1. Please help, thanks.

2
  • were you able to fix the problem?
    – Ken
    Commented May 30, 2013 at 17:41
  • Just the document library worked for me. <Receivers Scope="Web" ListUrl="Doc Lib Name">
    – Ken
    Commented May 30, 2013 at 17:51

3 Answers 3

2

Remove 'Forms' from the Url, the ListUrl should only point to the document library.

Next, visit the library in the browser. The url is relative to the web site url. So if your library is at:

http://webapp/sites/somesite/subsite/Lists/Temporary then the ListUrl is Lists/Temporary.

5
  • Thanks for replying. My Temporary library is at http://spserver/sites/site1/temporary There is no "Lists" part as it is not a list; it is a document library. The scope of the feature containing the event receiver is Site, not Web, and I need to keep it that way. Could that be the cause of the issue?
    – Boris
    Commented Mar 11, 2013 at 22:51
  • It doesn't work after all... It is now working on every single document library, regardless of the fact that I specified <Receivers ListUrl="Lists/Temporary">!!! Help?
    – Boris
    Commented Mar 11, 2013 at 23:00
  • Get rid of the lists part but keep the /
    – James Love
    Commented Mar 12, 2013 at 8:07
  • It is still doesn't work as expected. My event receiver is fired when I am adding new documents both to the Shared Documents and the Temporary libraries. It appears that the ListURL property is just ignored ...
    – Boris
    Commented Mar 13, 2013 at 15:58
  • Out of curiosity, is this in a Sandboxed solution?
    – James Love
    Commented Mar 13, 2013 at 19:45
1

This should work

<Receivers Scope="Web" ListUrl="Doc Lib Name">
0

Just to contribute eventhough it is closed.

Pay attention to this as you should supply the url of the document library and not the display name.

E.g.:
Document Library URL: http://myserver.local/deliverynoteinbound
Document Library Title: Delivery Note Inbound

For a document library your code should look like this:

<Receivers ListUrl="deliverynoteinbound"> //It should be the URL not the Title

And for a list it should be like this:

<Receivers ListUrl="Lists/somelisturl"> 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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