1

Let's say I've a managed/un-managed package to be installed in an Org. I want the Application to have an optional dependency on Omni-Channel feature.

Right now, we have referred the omni channel objects in the classes and hence we get error when trying to install the package without the Omni Channel Enabled in a Salesforce Org.

enter image description here

My question is, at this point, does Salesforce allow optional dependency while installation?

I mean either not to throw the error during the installation but at the time actual controller is referred or to hide the usage by checking while installing the package.

I understand that this is similar to compile time error where the actual object/class is not available for the user in the environment.

Thanks in Advance!

1 Answer 1

1

My understanding is that the mechanisms you mention or similar mechanisms that might help in this area are not supported. But I would be very happy to be wrong about that...

An approach we have used to avoid baking in a dependency on SObjects in another package is to check if the SObjects are present via Schema.globalDescribe() and then if they are only use dynamic SOQL and the base SObject class get/put methods to access the data. That avoids a compile-time and therefore a package dependency.

Avoiding dependency on classes is much harder and more unwieldy - see e.g. Breaking managed package dependencies. Both packages have to be designed to support the mechanism. Not something you would want to do on more than a few major interfaces.

Both of these techniques have to be planned in up front as the required code is substantially different to the code you would more naturally write. And once a dependency has been added between packages, I'm fairly sure it can't be removed i.e. the packaging process keeps the dependency requirement even if it doesn't exists in a later version so re-factoring in later versions to remove the dependency gets you nowhere.

1
  • Thanks! That really helped. Since its more of a POC at this point, I prefer the dynamic SOQL option. Breaking managed package dependencies was a good read indeed! Worth exploring while developing a whole suite of Apps. Thanks again! Commented Mar 14, 2016 at 8:58

You must log in to answer this question.

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