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'); }
and
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 what I want: https://cs1.salesforce.com
?
Here's something that I used within my Apex Trigger
System.URL.getSalesforceBaseUrl().getHost().remove('-api' );
This gives me proper URL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With