I have a custom object called Feedback that has a name field. I have set up an email alert every time a feedback is created. But I'm unable to add a link back to the feedback created(in salesforce) in the email template. Following is my code...

<messaging:emailTemplate subject="New Feedback Created" recipientType="User"       
  <messaging:plainTextEmailBody >
   Dear {!recipient.name},

    A new feedback created. Check now!
    Click https://na15.salesforce.com/{!relatedTo.Feedback__c.name}


Is it possible to add a link without adding a controller? Please guide me. Thanks

  • 1
    Try change relatedToType="Feedback__c" and in your code use {!relatedTo.Name} Commented Apr 15, 2014 at 2:38
  • Thanks @Bachovski ..changing {!relatedTo.Id} did the trick. I will update the answer.
    – MnZ
    Commented Apr 15, 2014 at 2:48

1 Answer 1


With the email templates, you need to use the sObject which the email template will be related to. In this case, if you have an email template that you're going to use with your "Feedback" custom object, your email template should be related to Feedback__c rather than Account (see relatedToType parameter).

Then when you're merging fields, the variable {!relatedTo} represents your sObject and in your case will be {!relatedTo.Name} if you want to display the feedback record name in your email.

  • Thanks @bachovski ..changing relatedToType="Feedback__c" and {!relatedTo.Id} did the trick. I will update the answer =)
    – MnZ
    Commented Apr 15, 2014 at 2:49
  • Same scenario i am unable to display the {!relatedTo.Name} in HTML visualforce email template, how can i achieve this?
    – Sfdcprgmr
    Commented Aug 11, 2021 at 7:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .