You need to sign in to do that
Don't have an account?
Nathan A
Getting the URL for the current organization instance at runtime.
I'm having a problem surrounding the use of:
ApexPages.currentPage().getHeaders().get('Host');
Wherein I'm making that call inside a Trigger deployed by my package on a Custom Object that's also inside my package, and when that resolves at runtime on the client's instance it still returns my developer's account URL rather than the client's instance URL. Which makes about no sense at all.
How do I detect the URL of the instance that's actually running the code, rather than the URL of the instance where the code was developed originally?
Original structure of Saleforce URL is
https://[instance].salesforce.com/[object]/o
Try the following code to get the instance name from this line :
// To Get the current page url.
PageReference currentpageurl = ApexPages.currentPage();
String orgURL = currentpageurl.getUrl();
// Using the split method we will get Instance name.
orgURL = orgURL.split(‘.’)[0];
orgURL = orgURL.split(‘//’)[1];
Hope this helps.