AnsweredAssumed Answered

Complete (including subprocesses) process history

Question asked by mlegnani on Jul 15, 2011
Latest reply on Jul 19, 2011 by mlegnani
I'm trying to implement what I suppose to be a very simple and common functionality for my application: the complete (including subprocesses) process history of a process that is not completed. This could be very useful to the user, making him understand what happened before.

I'm realizing that its very difficult to implement since:
    * there is no way to obtain the processInstanceId of a completed subprocess (while the parent process is still alive) from the callActivity that generated it from the API;
    * I then looked the DB schema trying to implement that functionality by myself but I discovered that such data is not kept in activiti tables. Once completed the subprocess is removed from runtime tables and remains only in history tables but act_ru_execution has a super_exec_ field allowing to know which is the parent, while there is no such information in any historic table (am I right?);
    * I decided to add a new custom table to keep track of the parent-child relation in historic tables, adding an executionListener to populate it on start of any subprocess but then I read on the forum http://forums.activiti.org/en/viewtopic.php?f=6&t=1353 that using API in listeners is discouraged since "You shouldn't use activiti API from within TaskListeners (nor from ExecutionListeners or JavaDelegates), this can mess up transactions.". So I can't know the parent process since I cannot use a simple line like:
    ProcessInstanc parentProcess = runtimeService.createProcessInstanceQuery().subProcessInstanceId(execution.getProcessInstanceId()).list().get(0);
    Am I right?
Does anybody have any suggestion to solve my problem?
Thanks,
Massimo

Outcomes