0

I have requirements that I have created a VF Email template and I need to add the today date and next year date dynamically, Today is working fine as mentioned in code but when I try to add year+1 It is not showing next year. Also, I need to add a randomly generated number at the place of Application no. Please have a look at my code.

<messaging:emailTemplate subject="Welcome" recipientType="User" relatedToType="Contact" >

<messaging:attachment renderAs="PDF" filename="Certificate.pdf">

        <head>
            <title></title>
        </head>
        <body>
            <div style="width:95%;height:100%;border:15px solid  #000066">
                 <table width="100%" style="background-color:#D3D3D3;">
        <tr>
            <td rowspan="1" class="slds-text-title_caps" style="text-align:left">
                <img width="250px" alt="logo" src="{!$Resource.Abc}"></img>
            </td>
            <td rowspan="1" class="slds-text-title_caps" style="text-align:right;">
                <img width="100px"  alt="logo" src="{!$Resource.Members_Logo}"></img> 
            </td>
        </tr>
    </table>
    <table width="100%" style="background-color:#D3D3D3">

          <tr>
            <th class="slds-text-title_caps" style ="text-align:center">
                This Certificate valid from {!DAY(TODAY())}-{!MONTH(TODAY())}-{!YEAR(TODAY())} to {!DAY(TODAY())}-{!MONTH(TODAY())}-{!YEAR(TODAY())} 
            </th>
        </tr>
          
          <tr>
            <th class="slds-text-title_caps" style ="text-align:center">
               Application No. 
            </th>
        </tr>
          <tr>
            <th class="slds-text-title_caps" style ="text-align:center">
               1234567
               
            </th>
        </tr>
       
    </table> 
   </div>
 </body>
</html>
</messaging:attachment>

<messaging:htmlEmailBody >

1
  • I don't see a +1 in your expression This Certificate valid from {!DAY(TODAY())}-{!MONTH(TODAY())}-{!YEAR(TODAY())} to {!DAY(TODAY())}-{!MONTH(TODAY())}-{!YEAR(TODAY())} – cropredy Nov 11 '20 at 18:05
0

You could likely add these fields as background fields on the object itself, and avoid having the logic in the template at all. Then, when the business team changes the validity dates, the admin just has to update the formula.

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.