I have an event receiver written by someone else. It originally came with events for ItemCheckingIn and ItemCheckedIn, but we needed something to handle simple metadata updates, too. Since those don't necessarily require checkout/checkin in a document library, I added ItemUpdated to the code (I went to the properties of the event receiver thing in the project and selected "true" for that method, which added the empty method to my code, and xml goodies to elements.xml). I then tested this out and it did not work. That is, ItemCheckingIn and ItemCheckedIn still did their thing, but ItemUpdated did not. I then added ItemUpdating and tried that - still no luck.
Is there some step I'm missing here? People say all kinds of things about stuff being registered but seriously isn't that supposed to be handled by all the feature settings and stuff? Can you only add these things when you are first creating the eventreceiver in visual studio? It's not like there's an error or even would be an error - I copied the code from one of the original methods - the event just does not even fire.
Any clues out there?
Thanks,
- Matt
UPDATE **
After the answer below I got a bug up my rear and went back to my solution in Visual Studio, looking for more clues. It turns out that the "feature" has C# code related to my event reciever (FeatureName.EventReciever.cs). In there, the particular events being handled are assigned to a configurable content type (set in web.config) VIA CODE. Is this normal? Should I RTFM at this point and figure out how this stuff is really done? I thought the Elements.xml for the EventReceiver handled this...
Code for FeatureName.EventReceiver.cs:
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
try
{
SPWeb web = properties.Feature.Parent as SPWeb;
//di-associate CWTEventReceiver from CWT Print only content type
DisableCWTEventReceiver(web);
//associate CWTEventReceiver to content type as defined in configuration <activefields sharepointcontenttypename="CWT Print Only">
FmiMetadataMappingHandler mappingHandler = WebConfigurationManager.OpenWebConfiguration("/", web.Site.WebApplication.Name).GetSection(Utils.GetConfigSectionNameForWeb(web)) as FmiMetadataMappingHandler;
SPContentType ct = web.ContentTypes[mappingHandler.ActiveFields.SharepointContentTypeName];
if (ct != null)
{
Assembly assembly = Assembly.GetExecutingAssembly();
AssemblyName assName = assembly.GetName();
// bind event receiver to ItemCheckingIn Event
SPEventReceiverDefinition receiverCheckingIn = ct.EventReceivers.Add();
receiverCheckingIn.Name = "CWTEventReceiverItemCheckingIn";
receiverCheckingIn.Type = SPEventReceiverType.ItemCheckingIn;
receiverCheckingIn.SequenceNumber = 1000;
receiverCheckingIn.Assembly = assName.FullName;
receiverCheckingIn.Class = EVENT_RECEIVER_CLASS_NAME;
receiverCheckingIn.Update();
// bind event receiver to ItemCheckedIn Event
SPEventReceiverDefinition receiverCheckedIn = ct.EventReceivers.Add();
receiverCheckedIn.Name = "CWTEventReceiverItemCheckedIn";
receiverCheckedIn.Type = SPEventReceiverType.ItemCheckedIn;
receiverCheckedIn.SequenceNumber = 1001;
receiverCheckedIn.Assembly = assName.FullName;
receiverCheckedIn.Class = EVENT_RECEIVER_CLASS_NAME;
receiverCheckedIn.Update();
//update content type with event receiver
ct.Update(true);
}
}
catch (Exception ex)
{
Utils.LogError(ex.Message, ex.StackTrace);
}
}