I need to create a new section on a custom landing page that gives the User a list of objects that they can approve, as they are a member of a queue being submitted to.
The closest I can get is this :
List<Id> objectsUserCanApprove{
get{
List<Id> ids = new List<Id> ();
for (ProcessInstanceWorkItem item : [SELECT ProcessInstance.TargetObjectId
FROM ProcessInstanceWorkItem
WHERE ProcessInstance.Status = 'Pending'])
{
ids.add(item.ProcessInstance.TargetObjectId);
}
return ids;
}
}
//Followed By :
[SELECT Id, Name FROM customObject__c Where Id IN :objectsUserCanApprove) ORDER BY Submitted_Date__c];
But the problem arises with multi-level approval queues, the query returns objects that have already been approved by the current queue but have not been approved by the second queue. Is there anyway query ProcessInstanceWorkItems belonging to a specific queue?