Getting the latest running process instance

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Established Member

Getting the latest running process instance

Jump to solution

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 Solution

Accepted Solutions
Highlighted
Senior Member II

Re: Getting the latest running process instance

Jump to solution

runtimeService may not give what you want. 

The following should work.

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

View solution in original post

1 Reply
Highlighted
Senior Member II

Re: Getting the latest running process instance

Jump to solution

runtimeService may not give what you want. 

The following should work.

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

View solution in original post