SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If I create a custom list definition and instance in CAML, as part of a feature, and I have included a custom field as part of that list, will that field's OnAdded() method get called when the feature is deployed and activated?

Will it get called twice? (Once when adding the column to the site column collection, and once when the list instance gets created?)

share|improve this question
up vote 0 down vote accepted

No it wont get called twice.

The event receiver is configured at the list level and I believe it gets provisioned after the list has been created.

Therefore the only time that the SPField.OnAdded() event will get called is if a field is added within the context of the list and after the list has been created through Feature Receiver, UI etc.

share|improve this answer
Ok, so just to be clear then, the event won't fire with a straight CAML deployment where the field is already added to the list definition? In order for the event to fire I would have to deploy a feature where the list definition / instance does not contain the field, but the field definition is also included in the feature, and then through a Feature Receiver actively add the field to the list? (Obviously adding it through the UI would do it, but I'm trying to automate the deployment and ensure that the event gets fired as part of the deployment process.) – Dylan Cristy Feb 5 '13 at 20:45
Yes, sounds like we are on the same page. Your approach if valid, how about a slightly different approach? Refactor the code that the SPField.OnAdded() function is calling into a separate module called say WireUpField. SPField.OnAdded() calls the standalone WireUpField function. Add an event receiver to the feature which creates the list which calls into the WireUpField function. At least then that way you have one less feature receiver being called each time this list is created. Also you have more control over what that list deployment feature does. – Simon Doy Feb 6 '13 at 8:45
Interesting approach, I'll look into it. Thanks! – Dylan Cristy Feb 6 '13 at 13:30
No problem, so does that answer your question? hint, hint ;) – Simon Doy Feb 6 '13 at 15:07
Oh yeah, oops, sorry :) – Dylan Cristy Feb 6 '13 at 16:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.