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
OnDem DevOnDem Dev 

Embedding URL in Visualforce Email Template.

Hi,

 

I am creating Visualforce Email Template. In that i want to construct the URL using a custom object.

For example : <<URL of the org>>/Object.id

 

How can we get the current orgs URL as different orgs have different domains like na1, na2, tapp0 ?

 

Can anyone help me in getting the organizations URL? 

 

Regards,

Imran

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

This has been asked several times, but I've not seen/found any way of doing this.

 

My workaround is to create a custom setting containing the base server address and remember to change this when I refresh a sandbox.

 

 

 

All Answers

bob_buzzardbob_buzzard

This has been asked several times, but I've not seen/found any way of doing this.

 

My workaround is to create a custom setting containing the base server address and remember to change this when I refresh a sandbox.

 

 

 

This was selected as the best answer
KarteekKumarMKarteekKumarM
Hey, This is easy in a VF email template. {!LEFT($Api.Partner_Server_URL_140, FIND(".com/",$Api.Partner_Server_URL_140)+3)} However, this is not available in Text email templates. Thanks & Regards, Karteek Kumar M
xxxxxxxxxxxxxxxx

This can be done using <Object Name>.Link

Works for all objects and for both Text and HTML templates.

See example below:

 

{!Account.Link}