中小学网站建设论文,网站建设项目经理,公司网站开发怎么做,wordpress3Foreword
目前SF暂未提供直接有效的方法在Apex获取SiteURL#xff0c;我们可以在Idea (Access URL for a Site or Community from Apex)页面投票#xff0c;除了下面提供的一种hack思路#xff0c;当然也可以通过Custom Label手动维护。
Format of Site URL Sandbox site …Foreword
目前SF暂未提供直接有效的方法在Apex获取SiteURL我们可以在Idea (Access URL for a Site or Community from Apex)页面投票除了下面提供的一种hack思路当然也可以通过Custom Label手动维护。
Format of Site URL Sandbox site url: “http://{sandbox-name}–{subdomain}.{salesforce-instance}.force.com” Enterprise edition site url: “http://{subdomain}.{salesforce-instance}.force.com” Format of Developer edition site url: “http://{subdomain}-developer-edition.{salesforce-instance}.force.com Customization
Step 1 : Create a apex class “siteurl” and paste the following code.
public with sharing class siteurl{/*** Webkul Software.** category Webkul* author Webkul* copyright Copyright (c) 2010-2018 Webkul Software Private Limited (https://webkul.com)* license https://store.webkul.com/license.html*/public List getSiteUrl(){ List siteList [SELECT GuestUserId, Name,MasterLabel, Subdomain, OptionsRequireHttps, UrlPathPrefix FROM Site WHERE Status Active Limit 1000];List siteFullUrlList new List();/** We can get instance of the org from organisation object **/Organization org [SELECT InstanceName,Name, IsSandbox, OrganizationType FROM Organization];if(siteList ! null siteList.size() ! 0) {for(Site s: siteList) {if(s.Subdomain ! null) {String httpStr http://;if(s.OptionsRequireHttps true) {httpStr https://;}String siteFullUrl httpStr;if(org.IsSandbox true) {siteFullUrl UserInfo.getUserName().substringAfterLast(.)-;}siteFullUrl s.Subdomain .;siteFullUrl (org.IsSandbox || org.OrganizationType Developer Edition ? (org.InstanceName.toLowerCase() .) : ) force.com;if(s.UrlPathPrefix ! null) {siteFullUrl /s.UrlPathPrefix; }siteFullUrlList.add(siteFullUrl);}}} return siteFullUrlList;}
}Step 2 : Create visualforce page with following code.
apex:page controllersiteurl!--/*** Webkul Software.** category Webkul* author Webkul* copyright Copyright (c) 2010-2018 Webkul Software Private Limited (https://webkul.com)* license https://store.webkul.com/license.html*/--apex:repeat value {!siteurl} vars{!s}br//apex:repeat
/apex:pageFinal Effect
Site URL List in Developer Edition Site URL List in sandbox