+ Start a Discussion
jaw999jaw999 

Approval History info in Visualforce Email Template

Getting all the useful info from approval history. I can get most, but a couple elude me - like the name of the Approval step! See:
 
<messaging:emailTemplate subject="Lead Final Approval" recipientType="User" relatedToType="Lead">

<messaging:htmlEmailBody >

//lots of other Lead fields

<p><b>Approval History:</b></p>
<table border="1" >
    
    <apex:repeat var="cx" value="{!relatedTo.ProcessSteps}">
        <tr>
             <td>Assigmed to: {!cx.OriginalActor.name}</td>
             <td>Actual Approver: {!cx.Actor.name}</td>
             
             <td>Step Name-ID(cx) : {!cx}</td>
            <td>Step Status: {!cx.StepStatus}</td>
            <td>Approvals Completed:{!cx.ProcessInstance.CompletedDate}</td>
            <td>Process:{!cx.ProcessInstance.ProcessDefinition.name}</td>
           
         
            
          <td>Comments:{!cx.Comments}</td>
        </tr>
         
    </apex:repeat>                 
</table>
<p />
</messaging:htmlEmailBody>
</messaging:emailTemplate>

The big problem line is <td>Step Name-ID(cx) : {!cx}</td>
It produces an id with an 04h prefix, so it's the Step, but how to the the NAME of the step?
I am just getting output like this for that line:Step Name- : 04hq0000000GkgFAAS
{!cx.name} for example does not compile. Thanks
ManojjenaManojjena
Hi ,
What actually you want to display in template in place of Id ,because in ProcessInstance and steps both do not have any Name field .That ia the main cause it is ahowing you error .

Could you please tell what exactly you wnat to display .
jaw999jaw999
I want to see the name of the approval step to match the approver's name and date I am getting. 
ManojjenaManojjena
Hey ,
Name in the sense whether it is submitted ,approved ,rejected ? If yes then you can get from StepStatus ,however submitted will display as started if you want you can display Submitted in place of started rest will be same .


 
jaw999jaw999
No, that would be status. I mean name of the Step - Initial Approval, Business Manager, etc. 
jaw999jaw999
The names under the Name column in the middle below - 
the name of the approval step - see Name column
ManojjenaManojjena
Hey,
This image is the  approval steps in your appoval process .Internally salesforce is storing data in ProcessInstance and ProcessInstanceSteps objects .You can query and check in workbench .