1
votes

I'm trying out this very simple scenario:

  1. Process 1 has two tasks (task A -> task B)
  2. Process 2 has one "call activity" block (calling Process 1).

So, I started Process 2. And it goes directly to a state where we have 2 executions:

  1. The one that directly maps to the instance of Process 2. Let's say: 123
  2. The one associated with the "call activity". Let's say: 456

The question is: how to easily find the task where Process 1 is currently at? (it should be Task A).

Well, I can do it with this REST queries:

  1. First I query all the executions that belong to Process 2: runtime/executions?processInstanceId=123

Here I get: [{id: 123}, {id: 456, activityId: "calling_subproc"}]

Well, I know that 456 is an execution of sub process, so the next query is:

  1. runtime/process-instances?superProcessInstanceId=123&includeProcessVariables=true

Here I get: [{id: 789, activityId: "task 1"}]

But..., I can do that because I know it is a sub-process, I designed the model. But ... otherwise, how will a program (ignorant of that fact) find out about it? There's nothing in the response from query #1 indicates that 456 is a subprocess (meaning I'll have to execute query #2..., rather than runtime/tasks?executionId=456&includeProcessVariables=true, which by-the-way gives me {data: [0], total: 0, start: 0, sort: "id", order: "asc", size: 0})

---- ADDITIONAL COMMENT : -----

I think the REST service runtime/executions should support "superExecutionId" parameter (e.g.: runtime/executions?superExecutionId=87519)... such that given the execution id (in the calling process), we can directly navigate to the spawned sub-process (the database structure supports that already):

enter image description here

Thanks in advance, Raka

1
For a moment, the workaround seems to be "having a unique process variable that's shared / copied across the calling process and all the called sub-processes": forums.activiti.org/content/…Cokorda Raka
Related: it is still not implemented (up to version 5.16.4), already in JIRA though: jira.codehaus.org/browse/ACT-1805 ref: forums.activiti.org/content/…Cokorda Raka
REST json of runtime/process-instances and runtime/executions need to be enriched with field "superProcessInstanceId" and "superExecutionId" respectively.Cokorda Raka

1 Answers

3
votes

This was a problem in a project I just finished. The solution/workaround was very much as listed in the above comment, we created a process variable to represent the "top level" process instance ID.

In order to make sure we didnt have to manually set this up for all called processes (i.e. didnt have to explicitly model the variable passing), we added a parse handler to add a start listener to automatically populate the variable when a called process is initiated.

Worked like a charm.