cancel
Showing results for 
Search instead for 
Did you mean: 

Getting the process ID of a called subprocess

floickelsheimer
Champ in-the-making
Champ in-the-making
Dear community,
I need some help with the following scenario:

Description of the situation:
I have got two processes, one parent process and one subprocess which is triggered by its parent via a call activity. The subprocess contains multiple user tasks where the user has to input various values. All process events (start events, task completion, etc.) should be triggered via REST API calls from external frontend systems.
To complete a task of a certain process instance, I usually do 2 webservice calls with the REST API: the first one is to get all open tasks for a certain process instance (processId) which normally returns the task ID. This task ID I use in a second call to complete the desired user task (with the corresponding values).

The problem:
The problem now is that I do not have the process ID of the subprocess. When starting the parent process via REST, I only get the process ID of the parent but not of the subprocess. Since the user tasks are part of the subprocess I have no possibility to complete these tasks then.
Therefore: Is there any possibility to get the process Id of a subprocess when having the process Id of its parent (for example in combination with the call activity)?

What I have tried (based on the Activiti userguide):
1.) Calling "Get Process Instance Details" of the parent process returns only the activityId of the call activity plus some additional attributes (but not of the called process).
2.) Calling "Get open tasks for a process instance" of the parent process returns an empty JSON object since there are no open tasks for the parent process at this stage.

Thanks a lot!
11 REPLIES 11

gokceng1
Champ in-the-making
Champ in-the-making
If I understand you correctly you do not need subprocess id for completing its tasks. When the state transfers from parent to sub-process you have at least one task (assuming the subprocess is not completely wait-state free) and calling:

Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();

with the processInstance which is your parent process you will get your task waiting for user action. As I know there is no REST/API method to complete subprocess completely. You need to complete subprocess's tasks one by one.
You need to check whether your process state is inside subprocess or not when you tried to call "Get open tasks for a process instance".

floickelsheimer
Champ in-the-making
Champ in-the-making
If I understand you correctly you do not need subprocess id for completing its tasks. When the state transfers from parent to sub-process you have at least one task (assuming the subprocess is not completely wait-state free) and calling:

Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();

with the processInstance which is your parent process you will get your task waiting for user action.

That is exactly what I wanted. But no, that does not work. It gives me an NPE when using Java and an empty JSON object when using the REST API.

jbarrez
Star Contributor
Star Contributor
Hmmm , seems to me the process instance details request should be enhanced to include that data … could you create a JIRA request for this?

frederikherema1
Star Contributor
Star Contributor
In rest, use process-instances?superProcessInstanceId=123 (see http://www.activiti.org/userguide/#restProcessInstancesGet). In java, there is a query-counterpart. This way, you can get the called process-instance. The other way around is also supported using subProcessInstanceId.

Hi, I have similar scenario , I need to query for all the active user tasks including from Sub process (Call Activity). When I query the task service using process Instance Id, I get only parent process user tasks. How to achievet that?

frederikherema1
Star Contributor
Star Contributor
There is no single query, for the moment, to do this. Alternative is to either 1) do a native task query (see API), 2) do multiple queries or 3) add jira requesting this feature, perhaps suggesting solution with pull-request

mikebrown01
Champ in-the-making
Champ in-the-making
Here is the work around we are using for this (see last post). It took me a few days to put all of the pieces together.
http://forums.activiti.org/content/get-all-active-tasks-including-sub-process-tasks

Activiti Team,  this scenario seems to come up quite a bit in these forums.
The use case is described perfectly by the OP where the deployment model is to use
Activiti in a "headless mode" where Activiti is only used for process orchestration and not for the UI/Forms.

It would save some of us a lot of head scratching if there was an official way to handle this and if it was
described as a usage scenario in the user guide.






frederikherema1
Star Contributor
Star Contributor
We should indeed consider enriching the task-query with the possibility to include sub-process tasks as well. Can you make a JIRA-issue for this, so we can schedule this accordingly?

mikebrown01
Champ in-the-making
Champ in-the-making
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.