• Dexter Ortega
  • NEWBIE
  • 0 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
SELECT Id, (SELECT Id, ActorID, StepStatus, Comments FROM StepsAndWorkitems)
FROM ProcessInstance

After submitting approval request:
Whenever I query processInstance and StepsAndWorkItems in the developer console I am getting two items under StepsAndWorkItems. One item has status of ‘Started’ and the second a status of ‘Pending’.

After rejecting approval request:
Whenever I query this in the developer console after rejecting the approval record I am also seeing two results under StepsAndWorkItems. One item with a status of ‘Rejected’ and a second item with a status of ‘Started’.

Test Scenario:
My custom object will create after submitting a request for approval.
I have a flow that triggers (with invocable method for query) whenever my custom object gets created or updated. Info from processInstance I want to copy over to my custom object. 

I want to retrieve the actorID(approver) by checking for the item with status of ‘Pending’. I am expecting this to be available after submitting the record, but whenever my flow queries ProcessInstance it is returning empty.

When my flow runs after rejecting the approval record, when the flow queries ProcessInstance, I am seeing three items under StepsAndWorkItems. An item with status of ‘started’, ‘pending’, and ‘rejected’. 

Why could this be behaving differently during my test scenario vs when I query in the developer console?