4

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"       
 relatedToType="account">
  <messaging:plainTextEmailBody >
   Dear {!recipient.name},

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

    Regards,
    {!recipient.name}
 </messaging:plainTextEmailBody>
 </messaging:emailTemplate>

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} – Boris Bachovski Apr 15 '14 at 2:38
  • Thanks @Bachovski ..changing {!relatedTo.Id} did the trick. I will update the answer. – MnZ Apr 15 '14 at 2:48
5

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 Apr 15 '14 at 2:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.