cancel
Showing results for 
Search instead for 
Did you mean: 

[Proposal] Linking process instances and users

marcus1
Champ in-the-making
Champ in-the-making
In Activiti users are linked to tasks through IdentityLink and can be queried using TaskQuery.candidateUser(…). Similarly, the ability to link users with process definitions has been added recently through ProcessDefinitionQuery.startableByUser(…).

However, unless I've missed something obvious, there seems to be no way to link users and process instances.

In our application we have the requirement for people to see a list of the running process instances they are involved in (i.e. they started it or own/have owned an associated task). We've implemented this with our table which stores user_id - instance_id - involvement_type, but this is obviously not ideal.

It would be great if it were possible to do this through the standard Activiti API.

I would suggest to do it as follows and am willing to implement it as such and contribute it through a Git Pull Request.

1. Add a column for process instance id to ACT_RU_IDENTITYLINK.
2. Where IdentityLinks for tasks are added also store the process instance id.
3. On process start add an IdentityLink to the instance id and the current users (obtained through IdentityService.authenticatedUser).
4. Add a filter method to ProcessInstanceQuery: involvedUser(String userId).

What do you think?
7 REPLIES 7

jbarrez
Star Contributor
Star Contributor
I don't see the point yet: if users have tasks, they are involved with the process instance. So isn't a query on the tasks enough to know which process instances people are involved? Also, typically people are not really interested in processes, but tasks in my opinion. But probably you have another use case in mind … maybe it helps to share it?

marcus1
Champ in-the-making
Champ in-the-making
Hi Joram,

Suppose that a user starts a leave request process. As soon as he submits the first form, he will no longer have an active task, so he is no longer associated with the process. However, the user is still interested in that status of this process. We want to show the process diagram with the current state (highlighting the current task, but also show the assigned users, submission times, etc) so the user can see what is happening with his request as it goes through the organisation. This is especially interesting for non-trivial processes in which many different users are involved.

frederikherema1
Star Contributor
Star Contributor
This is a typical use case that can be solved using a combination of activiti:initiator, variables, history and task/execution-listeners, and can be audited later on.

marcus1
Champ in-the-making
Champ in-the-making
Sure, that is how we've implemented it so far.

It just seems to me that it could be done so much simpler, more robust and more efficient if done within Activiti.

frederikherema1
Star Contributor
Star Contributor
After some discussion, it seems to be a valid use-case to involve people with a process. The suggested approach seems to be a good one, perhaps we should add a "runtimeService.addUserIdentityLink(processInstanceId, userId, role)" method, similar to the taskService.addUserIdentityLink() method.

It's great that you're willing to contribute this to the activiti project. I'll make sure I get the pull-request reviewed and into Activiti asap when you've finished the implementation. Don't hesitate to ask additional questions during development…

marcus1
Champ in-the-making
Champ in-the-making
Great. Will do.

marcus1
Champ in-the-making
Champ in-the-making