You need to sign in to do that
Don't have an account?
newbee developer
SOQL Query to get loggedin user's items to approve
Hi All,
I want to fetch items which loggedin user can approve and display in a pageblocktable.
Below is my code written so far -
set<Id> setOfKnowledgeArticleId = new set<Id>();
set<Id> setOfProcId= new set<Id>();
//Below code gets pending items from ProcessInstance.
listOfPending = [SELECT Id, TargetObjectId, Status, LastModifiedDate FROM ProcessInstance where Status='Pending' ORDER BY LastModifiedDate DESC ];
for(ProcessInstance ProcessInstanceObj:listOfPending )
{
//Getting TargetObjectId to query Title,Summary from Custom Object and display in table
setOfKnowledgeArticleId.add(ProcessInstanceObj.TargetObjectId);
// IDs to query the actor ID
setOfProcId.add(ProcessInstanceObj.Id);
}
listOfActors = [SELECT Id, ActorId FROM ProcessInstanceWorkitem where Id IN: setOfProcId ];
set<Id> setOfActId= new set<Id>();
for(ProcessInstanceWorkitem pwObj:listOfActors )
{
setOfActId.add(pwObj.Id);
}
setOfActId is empty here, even though i know it should not be empty.
Please suggest how to achieve this.
I want to fetch items which loggedin user can approve and display in a pageblocktable.
Below is my code written so far -
set<Id> setOfKnowledgeArticleId = new set<Id>();
set<Id> setOfProcId= new set<Id>();
//Below code gets pending items from ProcessInstance.
listOfPending = [SELECT Id, TargetObjectId, Status, LastModifiedDate FROM ProcessInstance where Status='Pending' ORDER BY LastModifiedDate DESC ];
for(ProcessInstance ProcessInstanceObj:listOfPending )
{
//Getting TargetObjectId to query Title,Summary from Custom Object and display in table
setOfKnowledgeArticleId.add(ProcessInstanceObj.TargetObjectId);
// IDs to query the actor ID
setOfProcId.add(ProcessInstanceObj.Id);
}
listOfActors = [SELECT Id, ActorId FROM ProcessInstanceWorkitem where Id IN: setOfProcId ];
set<Id> setOfActId= new set<Id>();
for(ProcessInstanceWorkitem pwObj:listOfActors )
{
setOfActId.add(pwObj.Id);
}
setOfActId is empty here, even though i know it should not be empty.
Please suggest how to achieve this.
May I suggest you please refer the below link for reference.
- https://salesforce.stackexchange.com/questions/113784/query-users-items-to-approve
hope it helps.Please mark it as best answer if the information is informative.so that question is removed from an unanswered question and appear as a proper solution.
Thanks
Rahul Kumar