0

Is it possible to work on multiple list item event receivers and multiple document libraries itemadded/itemupdated event handlers in a single WSP/single VS 2013 solution?

My requirement is to work on some 8 splists' itemadded event handlers and some 6 document libraries' itemcheckedin event handlers at once.
Is this achievable?

Or should I create a separate WSP for the SPList and separate WSP for document library. Because when we start creating the event handler there is no option to select multiple entities for item eventhandlers.

1

Yes, it's possible.

You need to add new Event Receiver using VS dialog 8 times, that will create 8 new event receivers for you, all in one solution and wsp.

You can even later merge them in one single Elements.xml if you prefer and use one single class to handle all these events, if this approach is convenient for you.

1

You can defintely have different event reveivers in the same solution/WSP package.
A WSP is a container that groups one or more features + independant artefacts lile DLL(s) _layouts pages, images or .js files.

An event receiver is a C# class: you can create as many classes as you want in the DLL. You can even have different ER events in the same class, like one ItemCheckedIn and one ItemAdded methods.

Also, if all the lists share the same ER logic, you actually need only one ItemAdded: the ER code can obvisouly be shared between different lists: it's only the code logic and it can run in different contexts, at the same time, etc.

The main difficulty is actually how to register the correct ER to the correct list.
This can be done in two ways:

  • declaratively (by the mean of a special XML file hosted by the feature). This requires you to know at design-time the IDs of the lists, or to attach the ER to all lists from a given type. This is not always possible.
  • the imperative/code approach. This required you to add a feature ER. A feature ER is a piece of C# code associated to your feature. It will run once when the feature is activated. In the code, you identify the lists you want to attach the list ER to, and you attach your class to them. See https://sharepoint.stackexchange.com/a/166683/35604 for more details.

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.