I am writing some Apex to query Approval processes.
The following SOQL query runs just fine in Developer Console Query Editor:
Select p.Id, p.ProcessInstanceId,
p.ElapsedTimeInDays,
p.ActorId, p.OriginalActorId, p.CreatedById, p.CreatedDate
from ProcessInstanceWorkitem p
but when I attempt to use the same SOQL query in an Apex method like so:
List<ProcessInstanceWorkItem> piwi = [Select p.Id,
p.ProcessInstanceId,
p.ElapsedTimeInDays,
p.ActorId,
p.OriginalActorId,
p.CreatedById,
p.CreatedDate
from
ProcessInstanceWorkitem p];
Then I receive an error:
No such column 'ElapsedTimeInDays' on entity 'ProcessInstanceWorkitem'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.
Can anyone explain why the field is not valid in Apex or how I can change the query to access this field?