You need to sign in to do that
Don't have an account?

How to access ProcessInstanceHistory for a record?
How does one access in Apex, the approval comments, history associated with a record that has gone through an approval process?
The Web Services API describes a ProcessInstanceHistory object - but also says it cannot be queried.
The documentation says:
object was created. You cannot use query().
To retrieve this object, issue a describe call on an object, which will return a query result for each ProcessInstance since theobject was created. You cannot use query().
To retrieve this object, issue a describe call on an object, which will return a query result for each ProcessInstance since theobject was created. You cannot use query().
Apex SObjectDescribe methods do not seem to provide a way to access the process history.
Any clarification/help with getting access to the Approval Process history for a record would be much appreciated.
Here's an example of the query you'd need to execute...
This example assumes you've got a custom object, Mileage, that has an approval process hooked up to it:
Select m.Name, m.Id, (Select Id, StepStatus, Comments, CreatedDate From ProcessSteps) From Mileage__c m
The approval comments are obtained from the sub-query on ProcessSteps.
That works. Thanks for the pointer.