We are developing a Salesforce managed package. This package could be used with or without communities.


We have developed the components using Network class to get the network id using:


When we are uploading the package the creation page is notifying that feature "Networks Enabled" is required to install the package.

We have tested that if we try to install the package in an org without Communities, package installations returns

This app can't be installed. There are problems that prevent this package from being installed. Missing Organization Feature: Networks


We have found a possible workarround but we don't know if there is any other option. The workarround is:

  1. Create a base package without communities logic.
  2. Create an extension package with communities logic. This package will contain a CommunityHelper class with references to Network class and some new fields.
  3. In the base package classes verify if CommunityHelper class exists using


  1. If CommunityHelper exists, use communities logic. If not exists, use standard logic.


Is there any other workarround to solve this?

Any help out there? Thanks in advance

1 Answer 1


This can be resolved with Dynamic SOQL on "Network" object instead of using class Network.getNetworkId().

Boolean orgHasCommunity = false;
List<sObject> lstCommunity = [Select Id, Name, UrlPathPrefix from Network];
if(lstCommunity.size() > 0){
    orgHasCommunity = true;

You must log in to answer this question.

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