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
DannyTKDannyTK 

Adding a link to a record on an email template

Good afternoon community, 

 

So on a Visualforce Email template I'm trying to add a link back to the record detail page, with:

 

<apex:outputLink value="{!URLFOR($Action.Lead.View, relatedTo.id)}">
</apex:outputLink>

 

where related to type is my standard Lead object.  on Saving this template i continue to get this error:

Error occurred trying to load the template for preview: Invalid parameter for function URLFOR. Please try editing your markup to correct the problem

 

I'm not a developer by trade so not sure how to correct this, would appreciate any feedback regarding how to fix ....

 

thanks everyone

Best Answer chosen by Admin (Salesforce Developers) 

All Answers

Val ValinoVal Valino

Make it simpler for yourself and just have value="your-instance.salesforce.com/{!relatedTo.id}"

Val ValinoVal Valino
This was selected as the best answer
DannyTKDannyTK

Thanks Val, 

 

I appreciate the given direction, i'll just have to change my template from VF to HTML but think that it'll work.

DSupuran - MADSupuran - MA

I have a better solution  for you I've used as a workaround until salesforce fixes this.  Create a Visualforce Component (make the access level global), then you can referense an apex controller through the component.  From the controller expose a property or method which calls to Url.getSalesforceBaseUrl().toExternalForm() as the previous person had mentioned.

 

This way you can keep the Visualforce Email Template and not be forced to convert to another template type.