Im trying to convert my opportunity page to PDF (tru my custom button PDF).. on the bottom of the opportunity page, there`s a section called Approval process and Stage History..
I tried some query to get the processInstance value, but I cant get the StepsAndWorkItems value..
ERROR sObject type 'StepsAndWorkitems' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.
and as the result, if I click the PDF button, there`s an error "Attempt to de-reference a null object"
Here`s my query
piList = [SELECT Id, TargetObjectId, ProcessDefinition.Name, Status, CompletedDate, LastActor.Name,
(SELECT Id, StepStatus, Actor.Name, OriginalActor.Name, Comments, ProcessNodeId, ProcessNode.Name, CreatedDate
FROM StepsAndWorkitems ORDER BY Id DESC)
FROM ProcessInstance WHERE TargetObjectId = :idsf ORDER BY Id DESC];
count2=0;
wrppi = new List<wrapper>();
wrppih = new List<wrapper>();
for(ProcessInstance piL: piList){
wrapper wpi=new wrapper();
count2++;
wpi.cou=count;
wpi.pInstance = piL;
wrppi.add(wpi);
List<ProcessInstanceHistory> pihList2 = new List<ProcessInstanceHistory>();
pihList2 = piL.getSObjects('StepsAndWorkitems');
for(ProcessInstanceHistory pih: pihList2){
wrapper wrpih=new wrapper();
count3++;
wrpih.cou=count;
wrpih.piHistory = pih;
wrppih.add(wrpih);
}
}
}
public class wrapper{
Public integer cou {get;set;}
Public OpportunityLineItem oppChild{get;set;}
Public ProcessInstance pInstance{get;set;}
Public ProcessInstanceHistory piHistory{get;set;}
}
And this is my vfpage
<div style="">
<div Style="margin-top:15%; " ><p Style="font-size:18px;" ><b>
Approval History
</b>
</p>
<table class="body" style = "text-align: center;font-size:14px; spacing:-1px; border:solid 1px black; ">
<th style="width:10%; border:solid 1px black;">Date</th>
<th style="width:10%; border:solid 1px black;">Status</th>
<th style="width:10%; border:solid 1px black;">Assign To</th>
<th style="width:10%; border:solid 1px black;">Actual Approver</th>
<th style="width:15%; border:solid 1px black;">Comments</th>
<th style="width:10%; border:solid 1px black;">Overall Status</th>
<apex:repeat value="{!wrppi}" var="piObject">
<tr>
<td style = "width:10%; text-align: center;font-size:14px; spacing:-1px; border:solid 1px black;">{!piObject.pInstance.CompletedDate}</td>
<td style = " width:10%; text-align: center;font-size:14px; spacing:-1px; border:solid 1px black;">{!piObject.pInstance.Status}</td>
<td style = "width:10%; text-align: center;font-size:14px; spacing:-1px; border:solid 1px black;">{!piObject.piHistory.Actor.Name}</td>
<td style = "width:10%; text-align: center;font-size:14px; spacing:-1px; border:solid 1px black;">{!piObject.pInstance.LastActor.Name}</td>
<td style = "width:10%; text-align: center;font-size:14px; spacing:-1px; border:solid 1px black;">{!piObject.piHistory.Comments}</td>
<td style = "width:10%;text-align: center;font-size:14px; spacing:-1px; border:solid 1px black;">{!piObject.piHistory.Comments}</td>
</tr>
</apex:repeat>
</table>
</div>
</div>