Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
    
were you able to fix the problem? –  Ken May 30 '13 at 17:41
    
Just the document library worked for me. <Receivers Scope="Web" ListUrl="Doc Lib Name"> –  Ken May 30 '13 at 17:51
add comment

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer
    
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 Mar 11 '13 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 Mar 11 '13 at 23:00
    
Get rid of the lists part but keep the / –  James Love Mar 12 '13 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 Mar 13 '13 at 15:58
    
Out of curiosity, is this in a Sandboxed solution? –  James Love Mar 13 '13 at 19:45
add comment

This should work

<Receivers Scope="Web" ListUrl="Doc Lib Name">
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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