I have a requirement where in I have to put a link in the email sent to Lead after the web to lead creation. I need to add the Id of freshly created Lead to the link inside the email body sent to that particular lead.

When I try using Lead auto response rule, data in merge fields are not displayed. but, when I check it using " Send test and Verify Merge fields" button I can see the data.


<messaging:emailTemplate subject="Invitation" recipientType="Lead" relatedToType="Lead">
<messaging:htmlEmailBody >

This is your new Visualforce Email Template.



Am I missing something? As per my understanding, this should work.

PS: The same template if used in the workflow is working fine. I need to utilize the Assignment rules that's the reason I am not going with Workflow rule.

Any Help is appreciated ! thanks

  • Are you using the System Admin Profile? Apr 23, 2017 at 0:02
  • yep ! @CarlosNaranjo . The thing is , I need to send some redirecting links inside this email. So I need Lead Id and Name to pass it in the URL . But , I am not getting the merge field values when I create a lead. but when I use "Send test and Verify Merge fields" button its working fine. Apr 23, 2017 at 0:05
  • are you using web-to-lead through API? Apr 23, 2017 at 0:48
  • @SantanuBoral I hope its an API call as we see its a POST Method. Apr 23, 2017 at 9:43
  • If this template is only used for Web-To-Lead, try using either the Who.Id, What.Id or Lead.Id and see if one of those doesn't solve your issue.
    – crmprogdev
    Apr 23, 2017 at 15:02

1 Answer 1


I was able to fix it by replacing relatedTo.Id with the recipient.Id then it was giving the created lead record in the email. As I know, recipient is the one who receives and related To is the object whose merge fields are being populated right?

You must log in to answer this question.

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