DomainCreator クラス
DomainCreator クラスを使用すると、組織固有のホスト名が返されます。例えば、組織の Visualforce ホスト名を取得します。値は MyDomainName.lightning.force.com などのホスト名として返されます。
名前空間
例
次のコード例では、組織の [私のドメイン] のログインホスト名と uat パッケージの Visualforce ホスト名が取得されます。
1//Get the My Domain login hostname
2String myDomainHostname = DomainCreator.getOrgMyDomainHostname();
3
4//Get the Visualforce hostname
5String vfHostname = DomainCreator.getVisualforceHostname('uat');この場合、[私のドメイン] の名前が mycompany の本番組織では、myDomainHostname で mycompany.my.salesforce.com が返されます。また、同じ本番組織では、vfHostname で mycompany--uat.vf.force.com が返されます。
次のコード例では、Salesforce 取引先レコードへのリンクが作成されます。この組織に関連付けられている Lightning ホスト名が取得されます。次に、取引先レコード ID が取得され、連結を使用してリンク URL が作成されます。
1//Get the org’s Lightning hostname
2String myLightningHostname = DomainCreator.getLightningHostname();
3
4//Get the ID of a record Account with the name ‘Acme’
5Account acct = [SELECT Id FROM Account WHERE Name = 'Acme' LIMIT 1];
6
7//Build the URL to view the account record
8String fullRecordURL = 'https://' + myLightningHostname + '/lightning/r/Account/' + acct.Id + '/view';DomainCreator のメソッド
DomainCreator のメソッドは次のとおりです。
getExperienceCloudSitesBuilderHostname()
署名
public static String getExperienceCloudSitesBuilderHostname()
戻り値
型: String
getExperienceCloudSitesHostname()
ExperienceCloudSitesSubdomainName.force.com など、組織の Experience Cloud サイトのシステム管理のホスト名を返します。デジタルエクスペリエンスが有効でない場合、このメソッドでは InvalidParameterValueException が発生します。
署名
public static String getExperienceCloudSitesHostname()
戻り値
型: String
getExperienceCloudSitesLivePreviewHostname()
署名
public static String getExperienceCloudSitesLivePreviewHostname()
戻り値
型: String
getExperienceCloudSitesPreviewHostname()
署名
public static String getExperienceCloudSitesPreviewHostname()
戻り値
型: String