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
pavan.elthepu1.392651269495206E12pavan.elthepu1.392651269495206E12 

Email Template: Populate merge fields

Hi all,

I want to popuate merge fields in email template, and generate PDF. How can I achieve this? Please help me

Thank you,
Pavan
gyani19901.3956550919266765E12gyani19901.3956550919266765E12
Hi Pavan
you can merge field in the email template as shown in the below image then copy and paste that field in the email template.
User-added image

Regards,
Gyanender Singh
pavan.elthepu1.392651269495206E12pavan.elthepu1.392651269495206E12
Thank you Gyani for your reply. My question is how to populate the merge fields with the record values in apex code, and generate PDF?

Thanks in advance.
gyani19901.3956550919266765E12gyani19901.3956550919266765E12

Hi Pavan,

There are two ways.
1. If you are using standard controller on the vf page then use standard controller name and field name.
for example : suppose that standard controller name is Account and use want to merge name field then use ( {!Account.Name} )
2. If you are using custom controller on the vf page so first create list in the constructor and fetch field using soql in the controller and then use on the vf page.
for example : list name is ABCList and field name is Name then on the vf page use ( {!ABCList[0].Name} )

For pdf page use renderas="PDF" in the vf page.

Please let me know if you have any doubt or any other issue.

Regards,
Gyanender Singh

pavan.elthepu1.392651269495206E12pavan.elthepu1.392651269495206E12
No, I want to use email template. Not visual force page