function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
nirpnirp 

Write code for community without forcing installing org to enable the feature

Hi,

I would like to include some specifc code in my package for community users.
I don't want to enforce enabling of the community feature in the installing org, but only to use it in case the community feature is enabled.
Currently, after adding the code, I get Missing Organization Feature: CommonPortal null  when installing the packgage on orgs that doesn't support community.
What is the best practice to incorporate the code in the package without forcing the installing org to support this feature?

Thanks,
Nir
Best Answer chosen by nirp
Daniel BallingerDaniel Ballinger
You will need to make all Apex and SOQL references to the specific feature dynamic. This will remove the explicit dependency of a certain feature being available to install your managed package.

See:

All Answers

Daniel BallingerDaniel Ballinger
You will need to make all Apex and SOQL references to the specific feature dynamic. This will remove the explicit dependency of a certain feature being available to install your managed package.

See:
This was selected as the best answer
nirpnirp
Thanks Daniel.
I was able to change the relevant code to use dynamic APEX and SOQL.
The one thing I didn't manage to do is to call a static method dynamically, I want to call Network.getLoginUrl static method.
Can you help with that?