You need to sign in to do that
Don't have an account?
Jan Julian
Retrieve salesforce instance instead of visualforce instance
From a visualforce page, I need to retrieve our organization's salesforce instance's URL, and not the visual force URL.
For example I need https://cs1.salesforce.com instead of https://c.cs1.visual.force.com
Here's what I've tried so far and the outcome I got:
- Accessed the Site global variable from the VF Page .
<apex:outputText value="{!$Site.Domain}" /> returns null
Sidenote: Everything in $Site.xxx seems to return null. - From the Apex controller
public String getSfInstance() { return ApexPages.currentPage().getHeaders().get('Host'); }
public String getSfInstance() { return URL.getSalesforceBaseUrl().toExternalForm(); }returns c.cs1.visual.force.com and https://c.cs1.visual.force.com, respectively.
Question: How do I retrieve the right instance: https://cs1.salesforce.com?
you will the main host name fromt the below try this
system.debug(apexpages.currentpage().getheaders().get('X-Salesforce-Forwarded-To'));