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
NarenKNarenK 

Getting complete URL of logged in SF instance

Hi All,

 

I need to get complete URL of the salesforce into which user logged in. Currently when I tried to get URL using ApexPage.getCurrentPage().getUrl(). It only giving me path to the page not give complete URL like https://na1.salesforce.com/testpath.

 

Could any one of you let me know how can I address my problem.

 

Regards,

Naren

bob_buzzardbob_buzzard

You can use the  getCurrentRequestUrl method of the System.URL class for this.

 

E.g. 

 

String url=System.URL.getCurrentRequestURL().toExternalForm();
System.debug('Url = ' + url);