cancel
Showing results for 
Search instead for 
Did you mean: 

Get process instance ID based on Process identifier

aextractor
Champ on-the-rise
Champ on-the-rise

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 2

cjose
Elite Collaborator
Elite Collaborator

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
Champ on-the-rise
Champ on-the-rise

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.