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
MJ09MJ09 

Opportunity.Link in a VF email template

I have a non-VF email template that uses Opportunity.Link to insert the Opportunity's URL into the message.

 

I have another email template, a VF email template, and I'd like to insert the Opportunity's URL into that one too. The VF email template is defined like this:

 

 

<messaging:emailTemplate subject="My Subject" recipientType="User"
relatedToType="MyObject__c">

where MyObject__c has a field, MyOpp__c, that's a lookup to an Opportunity

 

The following tries don't work -- I can't even save the email template:

URL: {! RelatedTo.MyOpp__c.Link }

URL: {! RelatedTo.MyOpp__r.Link }

 

 I know I can hard-code the first part of the URL to refer to the production URL, but that's not right if I'm sending the email from the sandbox.

 

Is there any (good) way to get the full URL into a VF email template?

 

Thanks!

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
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