2

I have a managed package that currently has a number of custom fields on Opportunity and OpportunityLineItem.

Some customers are now asking for similar functionality for Order and OrderItem.

If I add custom fields to Order and OrderItem and then bundle them in the managed package will I be creating a dependency on the Order feature being enabled? Not all orgs using the managed package will have the Order feature enabled.

I can use dynamic SOQL and schema metadata to remove explicit references to these custom fields from the Apex code, but I suspect the presence of the fields alone will be enough that the managed package would only install in Orgs where Orders are turned on.

How do people handle custom fields for optional Salesforce features?

Should I create a separate package that can optionally be installed to add the required custom fields for Order support? This secondary managed package would extend the first managed package. Maybe with defined interfaces in the base package that can be implemented in the secondary package and then invoked via reflection.


Update: I think I'm skirting around the concept of an extension package. I did find Supporting Multiple Editions using an Extension Package and Publishing Extensions to Managed Packages

1 Answer 1

2

Adding the fields will create the dependency that you do not want to have. Extension packages are pretty much the only way to go about this effectively; even if the fields didn't add the dependency and you used dynamic apex (as for record types etc.) the dynamic code can be very hard to cover in test methods on orgs that don't have the relevant feature enabled.

Creating an extension package will make your life far easier when it comes to supporting the Order and OrderItem functionality, you won't need dynamic code as you can assume the feature is enabled.

There's something of a fine line between using dynamic code and creating an extension, but it depends on what you're dealing with. If it's Chatter or RecordTypes then dynamic code can be workable albeit tricky, but the use of custom fields pretty much makes the decision for you in this case.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .