You need to sign in to do that
Don't have an account?
Get the instance url in apex code
Hi All,
Anybody know how to get the instance url in apex code. My requirement is such that , a mail should be sent to a user of the instance which containing hyperlink to a vf page something like "/apex/merge_profiles?id=....". Since I need to use absolute url to open salesforce page from gmail or any mail , I have to use the server name something like that na12 , ap1 ....
So the resultant url should become like "https://na12.salesforce.com/apex/merge_profiles?id=".
Since I cannot hard code the server name na12 or ap1, I should get it programatically.
Please share anybody know this...
Thanks in Advance,
Shebin Mathew
You can try
Following methods
Thanks
Nik
Skype Name : niket.chandane
Hello Nik,
First of all Thanks alot for your support.
My code is running in trigger and it is not related to a page so I cant use ApexPages.....
I got a solution which is Apex URL class there is one method getSalesforceBaseUrl().toExternalForm().
Currently I am doing testing for the same hope it will become success.
Anyway Thanks alot for your Kind Support.
Shebin Mathew
ohh Sorry Shebin. I was not aware that you are doing this coding in trigger.
But yes nice solution "getSalesforceBaseUrl().toExternalForm()"
Thanks
Nik
Thanks alot Nik
Have Fun with Apex and Visualforce...:smileyhappy:
Thanks alot.
Shebin....