How come I can compile a query on workitem to return processinstanceID but the related targetobjectid (and then of course the targetobjectid.name ) return the error:
Edit - sorry I wasn't clear but ultimately I want the targetobject's name field - to display to users.
ProcessInstance.TargetObjectId.name brings " Didn't understand relationship 'TargetObjectId' in field path.... type error"
Error: Compile Error: Didn't understand relationship 'ProcessInstanceId' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 15 column 50
public class UsersItemsToApprove {
public UsersItemsToApprove() {
}
public UsersItemsToApprove (ApexPages.StandardController controller) {
}
public List<ProcessInstanceWorkitem> getWorkItems() {
List<ProcessInstanceWorkitem> results = new List<ProcessInstanceWorkitem>();
List<ProcessInstanceWorkitem> allitems = [SELECT ElapsedTimeInDays,
ProcessInstanceId, ProcessInstanceId.targetobjectid
FROM ProcessInstanceWorkitem
WHERE ActorId= :UserInfo.getUserId()];
for(ProcessInstanceWorkitem thisitem : allitems)
{
results.add(thisitem);
}
return results;
}
}
ProcessInstance.targetobjectid FROM