cancel
Showing results for 
Search instead for 
Did you mean: 

Getting the latest running process instance

bhchemss
Star Contributor
Star Contributor

Hello everyone,

Is it possible to get the latest running process in Activiti with createProcessInstanceQuery ?

runtimeService.createProcessInstanceQuery().processDefinitionKey('myKey').active().singleResult().getProcessInstanceId() I want to get the process instance ID of that definition but only the latest running process.

Thank you

1 ACCEPTED ANSWER

cjose
Elite Collaborator
Elite Collaborator

runtimeService may not give what you want. 

The following should work.

historyService().createHistoricProcessInstanceQuery().processDefinitionKey("myKey").unfinished().orderByProcessInstanceStartTime().desc().singleResult()

View answer in original post

1 REPLY 1

cjose
Elite Collaborator
Elite Collaborator

runtimeService may not give what you want. 

The following should work.

historyService().createHistoricProcessInstanceQuery().processDefinitionKey("myKey").unfinished().orderByProcessInstanceStartTime().desc().singleResult()