DomainCreator Class

Use the DomainCreator class to return a hostname specific to the org. For example, get the org’s Visualforce hostname. Values are returned as a hostname, such as MyDomainName.lightning.force.com where MyDomainName is a placeholder value.

System

This example code fetches the org’s My Domain login hostname and the Visualforce hostname for the uat package.

In this case, in a production org with a My Domain name of mycompany, myDomainHostname returns mycompany.my.salesforce.com. And in the same production org, vfHostname returns mycompany--uat.vf.force.com.

This example code creates a link to a Salesforce Account record. It gets the Lightning hostname associated with this org. It then gets the Account record ID and uses concatenation to build the link URL.

The following are methods for DomainCreator.

Returns the hostname for content stored in the org, such as files.

public static String getContentHostname()

Type: String

Returns the hostname to access Experience Builder for the org’s Experience Cloud sites.

public static String getExperienceCloudSitesBuilderHostname()

Type: String

Returns the system-managed hostname for the org’s Experience Cloud sites, such as ExperienceCloudSitesSubdomainName.force.com, where ExperienceCloudSitesSubdomainName is a placeholder value. If Digital Experiences aren’t enabled, this method throws an InvalidParameterValueException.

public static String getExperienceCloudSitesHostname()

Type: String

Returns the hostname to access Experience Builder Live Preview for the org’s Experience Cloud sites.

public static String getExperienceCloudSitesLivePreviewHostname()

Type: String

Returns the hostname to access Experience Builder Preview for the org’s Experience Cloud sites.

public static String getExperienceCloudSitesPreviewHostname()

Type: String

Returns the hostname for the org’s Lightning Container Components.

public static String getLightningContainerComponentHostname(String packageName)

  • packageName: Type: String The package name for this component.

    If packageName is null, this method uses the org’s namespace prefix as the package name. Otherwise, it uses the default namespace.

Type: String

Returns the hostname for the org’s Lightning pages.

public static String getLightningHostname()

Type: String

Returns the hostname for the org’s My Domain login domain.

public static String getOrgMyDomainHostname()

Type: String

Returns the hostname for the org’s Salesforce Sites. If Salesforce Sites aren’t enabled, this method throws an InvalidParameterValueException.

public static String getSalesforceSitesHostname()

Type: String

Returns the hostname for the org’s setup domain, which hosts Setup pages in Salesforce.

public static String getSetupHostname()

Type: String

Returns the hostname for the org’s Visualforce pages.

public static String getVisualforceHostname(String packageName)

  • packageName: Type: String The package name for this component.

    If packageName is null, this method uses the org’s namespace prefix as the package name. Otherwise, it uses the default namespace.

Type: String