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:
- Create a base package without communities logic.
- Create an extension package with communities logic. This package will contain a CommunityHelper class with references to Network class and some new fields.
- In the base package classes verify if CommunityHelper class exists using
Type.forName('CommunityHelper')
- 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