cancel
Showing results for 
Search instead for 
Did you mean: 

Process Instance ID runtime viarable

jaco1
Confirmed Champ
Confirmed Champ

Hi. Is there a variable I can use that holds the process instance id that I can pass during runtime to a rest call in the payload ?

Like this

{
 "itemkey": "${id}"
}

1 ACCEPTED ANSWER

Hi Jaco,

That should work. If this approach does not work, you can have a global variable at the process level and update them at every step and you can access directly activiti_ru_variable . It also depends on if your process is synchronous/asynchronous and make sure the Rest call gets the right process id before it moves to the next step. 

In one of my use cases I use global variable to maintain the status of every task .That should definitely work .

View answer in original post

11 REPLIES 11

sarveshmvm
Confirmed Champ
Confirmed Champ

execution.getProcessInstanceId();

This will always gives you the current process instance ID. If you need to access the instance of the process(Root Instance id) , you can try the below

execution.getParentId()

Hi, Sathya G. Thanks for the reply. The problem I have is that I start a BPM process from an Oracle Apex Page.

When you start a process it will execute all the way until it gets to a Human Task and then it will return to the calling Apex Page.

As part of the process, there are REST calls back to Oracle Procedures that update worklist items before it gets to the first Human Task. Those procedures need values that live inside process instance variables. So for that Oracle procedure to get to the process variables I need the Process ID. I will only know what the process ID is once the call returns to my calling Apex Page. 

But if I can pass the Process id to the Oracle Procedure in the Rest call it will know what process to query on the Activiti side.

What I have done now is to place a Human task at the start with a timeout of 1 second. So when the Apex form creates the process it returns to the Form very fast and gives the Process Instance Id to the Form. The form then updates the request table with the Process ID. After the second when the process continues if will call the Oracle procedure than by this time now has the Process ID in the table and then all works.

Is there a default variable that I can use to pass the Process Instance ID to the Oracle Procedure via the payload?

Or can I use script code in that payload area to get the Process Instance ID ? There where I pass the CLAIM_NUMBER, I want to send the Process Instance ID also.

jaco1
Confirmed Champ
Confirmed Champ

can I do it like this ?

{

"itemkey": "${CLAIM_NUMBER}" ,

"processid": "${execution.getProcessInstanceId()}"

}

Hi Jaco,

That should work. If this approach does not work, you can have a global variable at the process level and update them at every step and you can access directly activiti_ru_variable . It also depends on if your process is synchronous/asynchronous and make sure the Rest call gets the right process id before it moves to the next step. 

In one of my use cases I use global variable to maintain the status of every task .That should definitely work .