+ Start a Discussion
trinitytrinity 

Approval fields in Visualforce email template

I am writing a custom Visualforce email template for one of approval process. When the request is approved, I want to add Approved By and Approval Comments fields in the template. Any idea how to do it?

 

<messaging:emailTemplate recipientType="User"

    relatedToType="Custom_Object"

    subject="Your Request has been approved: {!relatedTo.name}">

    <messaging:htmlEmailBody >

 

     <html>

        <body>

                <font face="arial" size="2">

 

              <p>*** REQUEST APPROVAL NOTIFICATION ***</p>

 

              <P>The following request has been approved.</p>

              <p> Request Name:                {!relatedTo.Name} </p>

              <p> Approved By: ???? </p>

              <p>Approval Comments:              ?????</p>

       <p />

       <p><a href="https://www.salesforce.com/{!relatedTo.id}">https://www.salesforce.com/{!relatedTo.id}</a></p>

 

         <p>Thank you.</p>

 

 </font>

        </body>

    </html>

 

    </messaging:htmlEmailBody>

sinsiterrulezsinsiterrulez

Hey you wont get that directly. You need to query the database (ProcessInstance object) with a filter of TargetObjectID as you record ID to get all the list of approval process data for that record.

You can do all this using an apex:component with an associated controller where you can query it.