05-15-2019 08:11 AM
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}"
}
05-16-2019 11:21 AM
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 .
05-15-2019 07:24 PM
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()
05-16-2019 04:06 AM
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.
05-16-2019 04:18 AM
can I do it like this ?
{
"itemkey": "${CLAIM_NUMBER}" ,
"processid": "${execution.getProcessInstanceId()}"
}
05-16-2019 11:21 AM
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 .
05-16-2019 01:00 PM
Hi. OK so this works if I keep the user task with the time out. I get this error if I do it all in one go.
Exception due to Activiti Object Not Found org.activiti.engine.ActivitiObjectNotFoundException: Could not find a process instance with id '30005'.
So it seems the process is synchronous as I can not access it from outside via the rest calls back to the process from the Oracle Procedures. It first needs to commit and return before I can access it. How do I make the process so it is asynchronous so I can call myself from a external oracle procedures during the start-up of the process ?
05-16-2019 01:23 PM
Thanks soooo much. I got it working now. I had to mark all the tasks as asynchronous and now it returns like when I do it with the timer. I am new to Activity. Been using Oracle Workflow for 20 years and now moving to BPMN solution. I know the concepts just not the Activiti implementation. But I am making progress every day.
Thanks for the help.
05-16-2019 01:24 PM
One last thin what is "activiti_ru_variable" .Googled it and I dont find any documentation about it.
05-16-2019 01:31 PM
act_ru_variable is a table where you can store the data objects . Data objects are nothing but the variables you define for the process and they are persisted into the database when you start a process. This can be used as a Global variable for the process and they can be accessed at any execution throughout the process.
execution.getVariable("Key","Value");
Make sure you set the value as a Map when you start a process else you will end up getting null values.
05-19-2019 03:46 AM
Thakn you for your reply. I created the variables as form variables. Like this.
Should I rather do it as Data Objects ?What is the pros and cons between the 2 ?
Regards.
Explore our Alfresco products with the links below. Use labels to filter content by product module.