2

I have two profiles Manager, Agent.

If Agent creates a record in case Object, that will escalate to Manager profile user for approval.

When Manager profile user login, I need to display all the case records which are in pending state. Please help to do this.

Thanks in advance.

1

The object which you are looking for is ProcessInstanceHistory. This read-only object shows all steps and pending approval requests associated with an approval process (ProcessInstance).

You can’t query ProcessInstanceHistory. Instead, you can query ProcessInstanceHistory by including it in a nested query on the parent ProcessInstance object. For example, the following SOQL query returns all the ProcessInstanceHistory records related to individual ProcessInstance records.

The nested query references StepsAndWorkitems, which is the child relationshipName for ProcessInstanceHistory in the ProcessInstance object.

SELECT Id, TargetObjectId, (SELECT Id, StepStatus, Comments FROM StepsAndWorkitems where StepStatus='Pending')
FROM ProcessInstance where TargetObjectId in: caseIds

See this thread for more information: How to Approve the record through Apex Programming.

  • Thanks for the response.But I want to get the pending records from a particular sObject (In my requirement, it is CASE object).How to identify the records belongs to CASE object? – manoj Jun 7 '16 at 10:11
  • i have updated my answer. i think you need to use the TargetObjectId field for retrieving only case object records – Mr.Frodo Jun 7 '16 at 10:22
  • TargetObjectId will return ID if the record.But how to verify whether it is belongs to CASE object ? – manoj Jun 7 '16 at 10:31
  • Like i did in the query.You need to only retrieve case records. – Mr.Frodo Jun 7 '16 at 10:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.