function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jyoti_tripathijyoti_tripathi 

Get data of standard Salesforce objects, which we cannot query.

Hi,

 

I want to get Data of ProcessInstanceHistory Object which does not allow queries on it.

 

I know we can query it through nested query, and I know that its a child object of ProcessInstance.

But how to access the data in child objects( ProcessInstanceSteps, ProcessInstanceworkITems, ProcessInstanceHistory)

 

Use Case: I want to display all pending approvals for a user on a VF Page.

When user select one of the appoval, all the history related to the approval process should be displayed. KInd of replicatind the home page for approval.

 

Thanks in advance,

Jyoti

Jia HuJia Hu

You can query like,

 

 

for(ProcessInstance pi : [SELECT Id, (SELECT Id, StepStatus, Comments FROM StepsAndWorkitems), (SELECT Id, StepStatus, Comments FROM Steps), (SELECT Id, ActorId, ProcessInstanceId FROM Workitems) FROM ProcessInstance limit 2] ) {

 if(pi.StepsAndWorkitems != null) {
   List<ProcessInstanceHistory> pihl = pi.StepsAndWorkitems;
   //add your code here
 }

 if(pi.Steps != null) {
   List<ProcessInstanceStep> pis = pi.Steps;
   //add your code here
 }

 if(pi.Workitems != null) {
   List<ProcessInstanceWorkitem> piw = pi.Workitems;
   //add your code here
 }

}