Currently, our managed package responds to DML events in real-time for a static set of standard objects we support. Our package achieves this real-time responsiveness through Apex Triggers, one for each object in the set. Consequently, our package cannot be installed in an org unless each of these objects exists in the org.
We have two GOALS:
Remove this limitation so that our package can be installed/upgraded regardless of which objects exist in the subscriber org.
Respond to DML events in real-time for ANY Salesforce object (we would prefer to use triggers to accomplish this).
I know of two high-level OPTIONS:
Move all object dependencies (including the triggers) to optional package extensions.
The major advantage of this option over option 2 below is that it doesn't require all unit tests in the subscriber organization's namespace to pass for the triggers to be deployed (according to http://www.salesforce.com/us/developer/docs/packagingGuide/Content/packaging_component_behavior.htm). However, there are several disadvantages of this approach including:- Complicates dev process.
- Subscribers have to install multiple packages to get real-time responsiveness.
- Complicates package UNinstallation.
- Set of real-time enabled objects is still static (unless we can dynamically create and install package extensions, which - correct me if I'm wrong - is impossible).
Dynamically deploy Apex Triggers to subscriber orgs (assume we are talking about production orgs for the purpose of this discussion).
- We've already done this using file-based Metadata API and the deploy() call, but it requires all unit tests in the subscriber organization's namespace to pass and, in our experience, they often fail. Given the frequency and difficulty of resolving these failures, we are looking for a better/more scalable/more customer-friendly solution.
QUESTIONS:
Is there a way to do option 2 (i.e., dynamically deploy Apex Triggers to subscriber orgs) that does not require all org's unit tests to pass?
If not, is there a better/more scalable/more customer-friendly way to do option 2?
What approach would you recommend to achieve goals 1 and 2 ... option 1? Option 2? Something else?
Any help would be much appreciated!!