9

Background

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

Issue

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

Network.getNetworkId();

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

Workarround

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

Type.forName('CommunityHelper')

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

Question

Is there any other workarround to solve this?

Any help out there? Thanks in advance

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;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.