Network Class

Represents a community.

Namespace

System

Usage

Use the method in the Network class to determine which community a user is currently logged into.

Network Constructors

The following are constructors for Network.

Network()

Creates a new instance of the System.Network class.

Signature

public Network()

Network Methods

The following are methods for Network. All methods are static.

communitiesLanding()

Returns a Page Reference to the default landing page for the community. This is the first tab of the community.

Signature

public static String communitiesLanding()

Return Value

Type: PageReference

Usage

If Communities isn’t enabled for the user’s organization or the user is currently in the internal organization, returns null.

forwardToAuthPage(startURL)

Returns a Page Reference to the default login page. StartURL is included as a query paremeter for where to redirect after a successful login.

Signature

public static PageReference forwardToAuthPage(String startURL)

Parameters

startURL
Type: String

Return Value

Type: PageReference

Usage

If Communities isn’t enabled for the user’s organization or the user is currently in the internal organization, returns null.

getLoginUrl(networkId)

Returns the absolute URL of the login page used by the community.

Signature

public static String getLoginUrl(String networkId)

Parameters

networkId
Type: String
The ID of the community you’re retrieving this information for.

Return Value

Type: String

Usage

Returns the full URL for the Lightning Platform or Experience Builder page used as the login page in the community.

getLogoutUrl(networkId)

Returns the absolute URL of the logout page used by the community.

Signature

public static String getLogoutUrl(String networkId)

Parameters

networkId
Type: String
The ID of the community you’re retrieving this information for.

Return Value

Type: String

Usage

Returns the full URL for the Lightning Platform page, Experience Builder page, or Web page used as the logout page in the community.

getNetworkId()

Returns the user’s current community.

Signature

public static String getNetworkId()

Return Value

Type: String

Usage

If Communities isn’t enabled for the user’s organization or the user is currently in the internal organization, returns null.

getSelfRegUrl(networkId)

Returns the absolute URL of the self-registration page used by the community.

Signature

public static String getSelfRegUrl(String networkId)

Parameters

networkId
Type: String
The ID of the community you’re retrieving this information for.

Return Value

Type: String

Usage

Returns the full URL for the Lightning Platform or Experience Builder page used as the self-registration page in the community.

loadAllPackageDefaultNetworkDashboardSettings()

Maps the dashboards from the Salesforce Communities Management package onto each community’s unconfigured dashboard settings. Returns the number of settings it configures.

Signature

public static Integer loadAllPackageDefaultNetworkDashboardSettings()

Return Value

Type: Integer

Usage

If Communities is enabled, and the Salesforce Communities Management package is installed, maps the dashboards provided in the package onto each community’s unconfigured dashboard settings. Returns the number of settings it configures. This method is invoked automatically during community creation and package installation, but isn’t typically invoked manually.

If Communities isn’t enabled for the user’s organization or the user is in the internal organization, returns 0.

loadAllPackageDefaultNetworkPulseSettings()

Maps the Insights reports from the Salesforce Communities Management package onto each community’s unconfigured Insights settings. Returns the number of settings it configures.

Signature

public static Integer loadAllPackageDefaultNetworkPulseSettings()

Return Value

Type: Integer

Usage

If Communities is enabled, and the Salesforce Communities Management package is installed, maps the Insights reports provided in the package onto each community’s unconfigured Insights settings. Returns the number of settings it configures. This method is invoked automatically during community creation and package installation, but isn’t typically invoked manually.

If Communities isn’t enabled for the user’s organization or the user is in the internal organization, returns 0.