1

Am wondering how to get usable info in the approval hisotry I can add to my visualforce email template. I have the below (UPDATED):

<messaging:emailTemplate subject="Lead Final Approval" recipientType="User" relatedToType="Lead">

<messaging:htmlEmailBody >
//lots of Lead fields    
<table border="0" >

<apex:repeat var="cx" value="{!relatedTo.ProcessSteps}">
    <tr>

        <td>Step Status: {!cx.StepStatus}</td>
        <td>Completed:{!cx.ProcessInstance.CompletedDate}</td>
        <td>Instance Status:{!cx.ProcessInstance.Status}</td>
        <td>Time:{!cx.ProcessInstance.ElapsedTimeInHours}</td>
        <td>Actor Id: {!cx.ActorId}</td>


    </tr>


  </apex:repeat>                 
</table>

    </messaging:htmlEmailBody>

    </messaging:emailTemplate>

It gets me stuff of partial value, for example:

Step Status: Approved Completed:Thu Mar 05 14:56:20 GMT 2015 Instance Status:Approved Time:0.003611111111111111 Actor Id: 005U0000000OnR8IAK
Step Status: Started Completed:Thu Mar 05 14:56:20 GMT 2015 Instance Status:Approved Time:0.003611111111111111 Actor Id: 005U0000000OnR8IAK Comments: Step Status: Approved Completed:Thu Mar 05 14:56:20 GMT 2015 Instance Status:Approved Time:0.003611111111111111 Actor Id: 005U0000000OnR8IAK
Step Status: Approved Completed:Thu Mar 05 14:56:20 GMT 2015 Instance Status:Approved Time:0.003611111111111111 Actor Id: 005U0000000OnR8IAK

Thus I can get related info from ProcessSteps to the ProcessInstance sometimes via

<td>Completed:{!cx.ProcessInstance.CompletedDate}</td>

but I want to get for example: Actor: {!cx.ActorId.User.Firstname}

1
  • Were you able to find the answer for bringing the name from the Actor ID? If yes, Could you please share with us? Thanks, Mounika – user21053 Jun 4 '15 at 22:05
1

Please use following so that you will get name:

Actor: {!cx.Actor.name}

I hope this will solve your issue

1
  • Sorry if it wasn't clear. I got actor name fine. What I don't have is the name of the step in the approval process. – jaw999 Aug 18 '15 at 12:13
0

I didn't understand your query correctly. There are many approval process related objects which you can query for your usage.

ProcessDefinition - Represents the definition of a single approval process.

ProcessInstance - Represents an instance of a single, end-to-end approval process. Use this and the node, step, and workitem process instance objects to create approval history reports.

ProcessInstanceHistory - This read-only object shows all steps and pending approval requests associated with an approval process (ProcessInstance).

ProcessInstanceStep - Represents one work item in an approval process (ProcessInstance).

ProcessInstanceNode - Represents a step in an instance of an approval process.

10
  • In my example I am using ProcessSteps as the related to as shown. It gives me Actor ID, which is the who, but how do I turn that into the person's name, for exmaple? – jaw999 Mar 19 '15 at 19:20
  • Updated code example in post – jaw999 Mar 19 '15 at 20:30
  • OK, i am getting more - almost all of the related fields except the Step Name - stepnode name but how to relate. Will probably find it soon... – jaw999 Mar 19 '15 at 20:47
  • what is the correct version of <td>Step: {!cx.ProcessInstance.ProcessInstanceNode.name}</td> to get the Approval Step's name? – jaw999 Mar 19 '15 at 20:51
  • What is relatedToType attribute in your template ? With the email templates, you need to use the sObject which the email template will be related to. If you have an email template that you're going to use with your "ProcessInstance" custom object, your email template should be related to ProcessInstance – Jarvis Mar 20 '15 at 4:40

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.