I am attempting to retrieve the current process instance step name based on the processInstance step but cannot figure out how to relate this to the processDefintion / ProcessNode.
My understanding is that the processNode
Describes a step in a process definition
while the processInstanceStep
is an instance of this ProcessNode Definition
. Can identify the latest processInstance for my custom object and can find the associated steps of that process. Using this query
set<Id> processInstanceIds = new set<Id>();
for (ProcessInstance pi : [ SELECT TargetObjectId, Status, CreatedDate,
(
SELECT Id, ProcessInstanceId, StepStatus, Comments, CreatedDate
FROM Steps
ORDER BY CreatedDate DESC
)
FROM ProcessInstance
WHERE TargetObjectId IN: wireRequestIds
ORDER BY CreatedDate DESC
])
What I need is now based on the latest step to get the step name..
ProcessInstanceStep:{ProcessInstanceId=04g4B0000006fFhQAI, Id=04h4B00000070O7QAI, StepStatus=Started, CreatedDate=2016-06-06 23:24:28}
ProcessInstance:{TargetObjectId=a4S4B000000CaRCUA0, Status=Pending, CreatedDate=2016-06-06 23:24:28, Id=04g4B0000006fFhQAI}
This leads me to the ProcessInstanceNode
.
But I cannot get this query to return anything..
list<ProcessInstanceNode> nodes = [SELECT Id, NodeStatus, ProcessNodeName, ProcessInstanceId
FROM processinstancenode
WHERE processinstanceid IN: processInstanceIds
AND nodeStatus = 'Pending' ];
Anyone done this before can send me in right direction??