Get process instance ID based on Process identifier

cancel
Showing results for 
Search instead for 
Did you mean: 
aextractor
Active Member

Get process instance ID based on Process identifier

Hi,

Did any one has an idea about how to get the process instance id of a running process by using a script task in another process in which i can enter the process identifier of the called process as input?

2 Replies
cjose
Senior Member II

Re: Get process instance ID based on Process identifier

Use the query api, something like below...Check Activiti User Guide - Query API for more details

runtimeService.createProcessInstanceQuery()

.processDefinitionKey("myProcessDefinitionKey")

.variableValueEquals("myVar", "someValue")

.list()

aextractor
Active Member

Re: Get process instance ID based on Process identifier

I adjusted your code according to my case of use as below:

runtimeService.createProcessInstanceQuery()

.processDefinitionKey("calledprocesstest")

.variableValueEquals("calledprocesstest_id", execution.getProcessInstanceId())

.list();

"calledprocesstest" is the process id of the process which i want to get its process instance id.

"calledprocesstest_id" is the variable that i want to set in the previous process instance id and map it in another process.

but it gives me "calledprocesstest_id" = empty

I don't know how to use your code correctly.