1

There is custom list definition and I have attached an event receiver on ItemUpdating of list instances from the custom list definition. For some reason, the Event Receiver doesn't seem to fire at all. The List Instance made from this list definition is a Hidden List (Not sure if this can be issue)

Following is elements.xml file for Event Receiver:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <Receivers ListTemplateId="10101">
      <Receiver>
         <Name>FBAMembershipReviewHandlerItemUpdating</Name>
         <Type>ItemUpdating</Type>
         <Assembly>$SharePoint.Project.AssemblyFullName$</Assembly>
         <Class>ProjectName.EventReceivers.FBAMembershipReviewHandler.FBAMembershipReviewHandler</Class>
         <SequenceNumber>10000</SequenceNumber>
      </Receiver>
    </Receivers>
</Elements>

Here is code file:

namespace ProjectName.EventReceivers.FBAMembershipReviewHandler
{
  /// <summary>
  /// List Item Events
  /// </summary>
  public class FBAMembershipReviewHandler : SPItemEventReceiver
  {
    /// <summary>
    /// An item is being updated.
    /// </summary>
    public override void ItemUpdating(SPItemEventProperties properties)
    {
       //my code here
    }
  }
}

What have I confirmed/tried?

. Confirmed that Custom List Definition List Template is "10101"
. Confirmed that the Event Receiver is deployed and feature is activated
. With the help of SharePoint Manager 2013 confirmed that the Event Receiver lists under the List
. Confirmed that the Event Receiver feature is deployed on Scope "Web" (I am not sure if this will effect)
. net stop/start sptimerv4 (each time I deploy the solution)
. IISReset each time I deploy solution
. Make sure not running updates from "System Account"

/******************* UPDATE ******************/
Seems like possible duplicate of following question
ListAdded Event Receiver not Firing for List Instances (I am also creating list via List Instance!)

1

The problem was same as mentioned in the duplicate Question.. When you have list instances deployed from your custom solution, the event receivers somehow doesn't seem to bind!

So you need to explicitly bind/attach event receivers on FeatureActivated event which deploys the List Instances, example shown below:

 list = web.TryGetList("ListName");

 if (list != null) {
    list.EventReceivers.Add(SPEventReceiverType.ItemAdding, Assembly.GetExecutingAssembly().FullName, "Namespace.ClassName");

    list.Update();
}

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.