1

I have a List Template DocLibTemplate with FeatureId : {00BFEA71-E717-4E80-AA17-D0C71B360101}. I am trying to have a event receiver subscribe to all libraries of this type. This is the code I have for the Elements.xml file for the event receiver.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Receivers ListTemplateId="101">
    <Receiver>
      <Name>EventReceiver1ItemAdded</Name>
      <Type>ItemAdded</Type>
      <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
      <Class>SharePointProject7.EventReceiver1.EventReceiver1</Class>
      <SequenceNumber>10000</SequenceNumber>
    </Receiver>
  </Receivers>
</Elements>

From my undesrtanding specifying that ListTemplateId="101" means the event handler will subscribe to Document Libraries. Is there a way to have it subscribe to only Document Libraries that use the DocLibTemplate either through the TemplateID of the template or the FeatureID, or can I create a new ContentType and have the list subscribe to that?

Edit : I found the xml file for the list template by downloading the list template stp file and unarchiving that. This had the manifest.xml file which contains the information.

2

Yes, you can do it through ListTemplateID on the event receiver and use the number you specified in the Type attribute in your list template declaration.

So for instance if your list template looks like:

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <!-- Do not change the value of the Name attribute below. If it does not match the folder name of the List project item, an error will occur when the project is run. -->
    <ListTemplate
        Name="My Custom List Template"
        Type="1234"
        BaseType="0"
        OnQuickLaunch="TRUE"
        SecurityBits="11"
        Sequence="360"
        DisplayName="My Custom List Template"
        Description="A template for lists of type My Custom Type."/>
</Elements>

Then in your event receiver, use:

<Receivers ListTemplateId="1234">
  • Since I have already created the ListTemplate DocLibTemplate where do I find this information for it? – belmer1416 Jul 26 '17 at 15:36
  • It should be in the Elements file for the list template. Can you post that XML? – Dylan Cristy Jul 26 '17 at 15:37
  • How do I access the elements file? – belmer1416 Jul 26 '17 at 15:40
  • How did you create the list template? I assumed you created it in Visual Studio since you have a Feature ID associated with the template. – Dylan Cristy Jul 26 '17 at 15:56
  • No I created a list and saved it as a template. – belmer1416 Jul 26 '17 at 15:57

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.