function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
EPSWDEVEPSWDEV 

Getting Site URL

I have Standalone Apex class that sends out and email and in which i wish to embed a link to custom object detail page. eg link would be http://na6.salesforce.com/somecustomobj.Id

 

my problem is I dont want to hard code the domain name in the url in my apex class so am trying to find out what class I can use to get my orgs url.  I tried touse the Site.getCurrentSiteUrl however no luck with that.  I use PageReference here either - apexpages.currentPage returns null so that no good either. Any help is appreciated.

 

Thanks

Message Edited by EPSWDEV on 01-30-2009 12:06 PM
aalbertaalbert

I just posted a blog post on a similar topic. It includes an example of how to capture both the Session Id and API Server URL from within Visualforce and setting the controller properties. You mention a "standalone" class so not sure if visualforce will help you, but worth mentioning. I also haven't tried this within the context of a Force.com Site.

 

Blog posting here

Rahul S.ax961Rahul S.ax961

Try This :) ,

 

String ServerUrl =  'https://'+ApexPages.currentPage().getHeaders().get('Host');
system.debug(ServerUrl);

 

With this you'll get something like this:

http://na6.salesforce.com

Furthur you can append id of any object in this string.