1

I am working on sharepoint server 2013. and i have developed an event receiver which fires when lists items are updated. now i define the following setting inside the elements.xml for my solution:-

 <Receivers ListUrl="Lists/Issue Manage">

so that the event receiver will only fire on the lists which have the following url Lists/Issue Manage. Then i try deploying the solution using visual studio 2012, but i got the following error:-

Error 1 Error occurred in deployment step 'Activate Features': The list "Lists/Issue Manage" doesn't exist. Please fix the ListUrl attribute. 0 0 CustomerSitesER

now i changed the feature scope from "Web" (which is the default) to "Site" , and try to re-deply the solution , where the solution got deployed without errors. so my question is why i can not use the ListURL when the solution scope is defined as Web?

second question now when i define the feature scope as Site the solution was deployed successfully, but the event receiver was fired on all the lists even the lists that does not have the following url ListUrl="Lists/Issue Manage". so not sure why this is happening ? as i know defining ListURL inside the feature's element.xml file should restrict the event receiver to got fired on the related lists only. but seems this is not the case.

Thanks

John John
  • 1
  • 44
  • 241
  • 563
  • 1
    this statement is wrong "only fire on the lists which have the following URL Lists/Issue Manage," only run on one list that has this path listURL path – Mohamed El-Qassas MVP Oct 12 '16 at 00:32
  • @M.Qassas i did not get your point ? now all the lists inside any site can be accessed from the following url "/lists/" so defining "list/Issue Manage" means to restrict the event receiver on all the list that can be accessed from "/lists/issue mnage" is this correct ?in all ways the event receiver is firing on all the lists.. so what is the reason ? – John John Oct 12 '16 at 01:02
  • this "list/Issue Manage" is the list path for a specific one list – Mohamed El-Qassas MVP Oct 12 '16 at 01:04
  • @M.Qassas but i have many subsites which have a list that can be accessed using "list/issue manage" ,, why you are assuming that i can only have one list with unique sub-url.. in my case i have 10 sub-sites and each sub-site have a list with the following url "http://servername/subsitename/list/Maage issue" ... in all ways why the event receiver is firing on all the lists ?? – John John Oct 12 '16 at 01:08
  • Should you join at this http://chat.stackexchange.com/rooms/46670/discussion-between-m-qassas-and-john-g to discuss in details – Mohamed El-Qassas MVP Oct 12 '16 at 01:36

1 Answers1

2

There seems to be some discrepancy. The error you are getting shows the Url as Lists/Risk Issue whereas the Url present in elements.xml file is Lists/Issue Manage.

ListUrl attribute works for Web based scopes and hence it will fire the events in all lists present in subsites where the feature is activated. Finally ListUrl attribute is ignored if scope of feature is changed to Site. See Event Receiver Firing for all Lists - even when ListUrl is set for more information.

Nadeem Yousuf-AIS
  • 18,707
  • 4
  • 28
  • 59
  • Sorry i wrongly typed the list URL. so the list url is "lists/Issue Manage". first question now in my case i set the scope of the solution as "Web" be selecting this from the Scope dropdown list , and i define the following inside the element.xml "" this mean that the event receiver should only work on document libraries.. but i tried adding an issue tracking item and the event receiver got fired!. – John John Oct 12 '16 at 12:31
  • second point now in my case the lists have the following display name "Manage" while their urls are "Issue Manage" as i have rename the lists long time ago (from "Issue Manage" to "Manage" using the UI).. so their names are different that their urls,, now when i use ListURL should i include the display name "Manage" or the url "Issue Manage". third point now regardless of using ListURL or ListTempleteid both is going to fire the event receiver for all the lists (so restricting the ER using these approaches are not working)...so what is the reasons? – John John Oct 12 '16 at 12:31
  • May I suggest you to try this on a fresh site collection? – Nadeem Yousuf-AIS Oct 12 '16 at 12:42
  • additional note now i have also tried to specify the scope inside the elements.xml as follow "" but still the event revicer will get fired on all the lists – John John Oct 12 '16 at 12:43
  • the problem is that my event receiver reference and use many custom site columns,, so it is not easy to create a new site collection with all the custom modifications inside it ..any other suggestions ?and can you please adivce on my above 3 question inside my comments ? – John John Oct 12 '16 at 12:45
  • You don't need to deploy whole solution of yours, just create an empty project with event receiver and check if above works in new site collection. That will determine if your current site is in good state or not. – Nadeem Yousuf-AIS Oct 12 '16 at 12:53
  • so what could be causing my site collection to be in a bad state ? as the event receiver is firing but it is firing on all lists ,, so this indicates that the problem might be within the event receiver itself and not inside the site collection is this correct ? – John John Oct 12 '16 at 13:23
  • second point i have, now i read a lot of articles where users reported that the ListURL is not working as expected. so to make things simpler, i can deploy the feature as-is with "listtempleteid=1100" (Issue Tracking),then inside my event receiver itself to add a condition to check the list name and/or the content type inside the Event Receiver, and then execute the update operations only if the list name and content type meet the requirements.in this case whenever the ER get fired, the actual update operations will not happen unless the list name and/or content type is met. what do u think? – John John Oct 12 '16 at 13:26
  • 1
    If that is the case you can programatically attach the event with a particular list. – Nadeem Yousuf-AIS Oct 12 '16 at 13:30
  • but in my case i have a list named "Manage" and this list can be found inside many sub-sites ,, and I want my event receiver to get attached to all the lists which have their names (title) = "Manage" so it is not a single list .. it is a list that can be found on multiple sub-sites... so i can define the scope of the event receiver to be Web , which mean the event receiver will get fired on all the lists inside the sub-site, but i will add a condition inside the ER to check for the list name ="Manage". – John John Oct 12 '16 at 14:35
  • ..i know this will cause the ER to get fired always(maybe a performance drawback) , but no effect will happen unless the items are under a list named "Manage",, i mean this appraoch is a workaround to the listurl and listtempleteid which seems is not working in my case.. what do you think ? – John John Oct 12 '16 at 14:35