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
KKBandi1KKBandi1 

Merge Fields work only when I use "Send Email and verify Merge fields " button but not on email sent when a lead is created from Web to lead form

Hi ,
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.

VF TEMPLATE:
<messaging:emailTemplate subject="Invitation" recipientType="Lead" relatedToType="Lead">
 <messaging:htmlEmailBody > Congratulations! This is your new Visualforce Email Template.
{!relatedTo.Id}
 </messaging:htmlEmailBody>
 </messaging:emailTemplate>


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
NagendraNagendra (Salesforce Developers) 
Hi Bandi,

Sorry for this issue you are encountering.

I have created the web2lead form.
<!--  ----------------------------------------------------------------------  -->
<!--  NOTE: Please add the following <META> element to your page <HEAD>.      -->
<!--  If necessary, please modify the charset parameter to specify the        -->
<!--  character set of your HTML page.                                        -->
<!--  ----------------------------------------------------------------------  -->

<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">

<!--  ----------------------------------------------------------------------  -->
<!--  NOTE: Please add the following <FORM> element to your page.             -->
<!--  ----------------------------------------------------------------------  -->

<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">

<input type=hidden name="oid" value="00D6F000001P4oY">
<input type=hidden name="retURL" value="http://login.salesforce.com">

<!--  ----------------------------------------------------------------------  -->
<!--  NOTE: These fields are optional debugging elements. Please uncomment    -->
<!--  these lines if you wish to test in debug mode.                          -->
<!--  <input type="hidden" name="debug" value=1>                              -->
<!--  <input type="hidden" name="debugEmail"                                  -->
<!--  value="ashusalesforce321@gmail.com">                                    -->
<!--  ----------------------------------------------------------------------  -->

<label for="first_name">First Name</label><input  id="first_name" maxlength="40" name="first_name" size="20" type="text" /><br>

<label for="last_name">Last Name</label><input  id="last_name" maxlength="80" name="last_name" size="20" type="text" /><br>

<label for="email">Email</label><input  id="email" maxlength="80" name="email" size="20" type="text" /><br>

<label for="company">Company</label><input  id="company" maxlength="40" name="company" size="20" type="text" /><br>

<label for="city">City</label><input  id="city" maxlength="40" name="city" size="20" type="text" /><br>

<label for="state">State/Province</label><input  id="state" maxlength="20" name="state" size="20" type="text" /><br>

<input type="submit" name="submit">

</form>

***********
VF template:

<messaging:emailTemplate subject="Invitation" recipientType="Lead" relatedToType="Lead">
<messaging:htmlEmailBody > Congratulations! This is your new Visualforce Email Template. {!relatedTo.Id} </messaging:htmlEmailBody> 
</messaging:emailTemplate>

**************
Assignment rule with status:
Lead: Lead StatusEQUALSOpen - Not Contacted
**************
The response which I am getting once the lead is generated on my email:

Congratulations! This is your new Visualforce Email Template. 00Q6F000014o9QVUAY

So everything is working as expected when I do "Send test and verify merge fields" button or when I submit the form from the web.

Please try with the above steps and let me know if you still facing this issue.

Please mark this as "Best Answer" if it resolves your issue.

Thanks,
Nagendra