How to access the processExecutionID of the currently created process.

cancel
Showing results for 
Search instead for 
Did you mean: 
imthiaz_d
Member II

How to access the processExecutionID of the currently created process.

Hi,

I am new to BPMN modeling and Activiti. I started working on it. I learnt to create a process by a post call

"runtime/process-instances" and passing the Process definition key to it.

I am able to mark the Tasks using "runtime/tasks/" + taskId" post call.

I am trying to implement an product ordering, manufacturing and delivering process. Lets call it order management system.

I want to map each order to the instance of the process created for it.

I am trying to set the variable order with the order ID while creating the process itself. like below

Map<String, Object> v =new HashMap<String, Object>();
v.add("orderID",orderId);

and passing the map to the post call like below

/runtime/tasks/" + taskId, pojo)

But thats not setting the process variable.

The other way is, I can set the process Execution Id on the order object and then I can map the process to the order object.

The problem is, I don't know how to access the processExecutionId of the currently created process.

It would be very help if the answer has some samples in it.

Thank you for the Help.

1 Reply
jearles
Established Member II

Re: How to access the processExecutionID of the currently created process.

Imthiaz,

I'm not sure, based on your comments whether you're doing all of this in Java or Javascript - can you give a little more detail on where you're trying to do this? Is it in Java or Javascript, or potentially all over REST?

At a brief level:
If you're doing this in Java, there is something called a RuntimeService, that has several methods to start processes. Each of these methods has an overloaded version that allows for a parameter that contains the variable utilized within the process. This blog post has a couple utilization examples of the RuntimeService.

If you're doing this in Javascript over REST, since you have access to the 'TaskId', you should be able to perform a GET /tasks/{taskId} which will include the executionId if it has been set by that time.

If you're doing this in the Javascript (Angular) of Activiti, these values exist inside the $scope variable - particularly $scope.task will contain the data you're looking for, depending on your location inside the app.

Hope this is a start, but I can help more with a little bit more context,
-JEarles