Saturday, 18 April 2015

SharePoint Event receiver triggering for all list .Need to trigger for only one list or one type of list


Hi one of the most common requirement in SharePoint is to have event receiver attached to a list .But when you add a event receiver item in Visual Studio and deploy .It will be attached to all the list .

Below are the few things you need to follow to attach a Event Receiver to particular list in SharePoint

1)In the Element.xml of Event Receiver change the tag property as below

         <Receivers ListUrl="Lists/List1">

This will attach the Event Reciever to only List1


2)Changing the tag as below

        <Receivers ListTemplateId="10001" >

will attach the Event Receiver to all the list in site which as listTemplateID =10001

These id are found when you create a list definition by yourself through Visual Studio.
Follow  this link Default list template Id to know about default list id of share point list.


Even after doing this few people see that Event Receiver is been attached to all the list .

The main reason for this is the Feature which is trying to activate the Event Receiver is at Site scope it has to be always at Web scoped . If it at Site scoped the ListUrl and ListTemplateId will be overridden and it will be attached to all the list in the site.

No comments:

Post a Comment