cancel
Showing results for 
Search instead for 
Did you mean: 

How to get sub-processes of a process?

former_member207065
Participant
0 Kudos

Hi,

I want to check whether a user has completed a task in a process. So I use

Set<TaskAbstract> getMyTaskAbstractsByParent(URI processInstanceId, Set<Status> statuses) in TaskInstanceManager. But it does not returns tasks of sub-processes. So I want to get the process instance ids of sub-processes by the parent process instance id.

In the latest API, there are only methods getting parent process instance id by sub-process instance id: getParentProcessInstanceId() and getRootProcessInstanceId(). How should I do?

Best regards,

Abe

Accepted Solutions (1)

Accepted Solutions (1)

AndreH
Employee
Employee
0 Kudos

Hi Abe,

getting the sub-processes of a process is not directly supported by the public API. In your case you could fetch all tasks for a user, get the corresponding process instance and check whether this process instance is the desired on or a child of it. You could do this, for example, as sketched with the pseudo-code snippet below.

Set<TaskAbstract> TaskInstanceManager.getMyTaskAbstracts(Set<Status> statuses)

for each TaskAbstract in Set

  ProcessInstance ProcessInstanceManager.getProcessInstanceForTaskInstanceId(URI taskInstanceId)

  if (ProcessInstance=parent or ProcessInstance.getParent()=parent)

    add to result Set<ProcessInstance>

Best Regards,

Andre

former_member207065
Participant
0 Kudos

Hi Andre,

Thank you for your reply. It seems that the method getParentProcessInstanceId() is available from NW7.31 SP08. Our NW is 7.31 SP05. Is there any other way?

-Abe

AndreH
Employee
Employee
0 Kudos

Hi Abe,

you are right, the method ProcessInstance.getParentProcessInstanceId() is only available starting with SP08. Unfortunately there isn’t any other way to get sub-processes with the public API.

You could at most try to find out whether a process/task is child of a particular process by analyzing the context of the sub-task/sub-process in your app. You could for example put the parent’s process instance ID into the input data object of the sub-tasks or any other special information into the subject of the sub-processes. Use methods like TaskDetail.getInputDataObject() or ProcessInstance.getSubject() to get this information in your app. But this is just a workaround, I would rather recommend you to go to SP08 and use the getParent method.

Best Regards,

Andre

former_member207065
Participant
0 Kudos

Hi Andre,

I have another question about your first reply. TaskInstanceManager.getMyTaskAbstracts(Set<Status> statuses)  will get all of somebody's tasks in some status e.g. status Completed. If someone has two many completed tasks, I am afraid that running that code will take some time and even degrade the server performance if many users having lots of completed tasks run that code at the same time.

Is my fear justified?

Best Regards,

Abe

ch_loos
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Abe,

here is what you can do:

1) Identify a unique context field (e.g. request ID, mat. no., order id...) that you pass from your main process to all subprocesses

2) write this context field along will the respective process instance ids into a CAF or JPA table

3) query all process instance ids for a given context key

4) get all tasks from all found process instance ids

Regards,

Christian

AndreH
Employee
Employee
0 Kudos

Hi Abe,

you are right, the operation getMyTaskAbstracts will query for example all the completed tasks of a user. This could be a costly query, especially in case of the completed tasks, but this depends on many things like the load on your server, your archiving strategy, the performance of your database, etc.

Best Regards,

Andre

Answers (1)

Answers (1)

junwu
Active Contributor
0 Kudos

you are embedding for referencing sub process?

can you put the process in context?

former_member207065
Participant
0 Kudos

Thank you for your reply. But sorry I can't get your meaning. Would you please clarify in detail?