Assign to User


#1

Hi everyone,

I want to assign a task to a user, but this user must not have already edited any tasks in the process.

Example:
I have one process. 3 user-task in a row and 3 different user.

  1. user-task-1 is done by user-1.
  2. Now user-task-2 can only be done by user-2 oder user-3.
  3. The last user-task-3 can only be done by user-2 (if user-3 has done user-task-2) or user-3 (if user-2 has done user-task-2)

Now also my question: It es possible to get all user, which have not checked one task in process instance? I want to use a Java Listener

Thank you.

Best regards,
Frederik


#2

@Fredo use the HistoryService to create task query. You are going to query for all tasks for your process instance. Then get the assignee of the task for each task. You can then manipulate your data to have a Map of [taskId : assignee] which you can then do your checks on who did which tasks.

For implementing actual restrictions, you could implement User Task Event Completion listener that checks whats going on and if being completed by the wrong user then throw a error which will trigger a rollback to before the task was submitted.

You could also implement a logic on the user task to determine if the User Task can be assigned/and thus claimed by a user. This would be a listener on the Assigned event. You would be checking against your Map and throw a exception if it fails to meet your logic.


#3

Everything Stephen said, but: querying the history service for runtime decisions can easily become a performance trap, since the historic data is fast growing. It may be worth considering an extra process variable for this kind of runtime data.


#4

@StephenOTT @jangalinski

Thank you for your quick feedback.

I will try to use the history service first, if I get performance problems, I switch to new variables.

Thanks again for your help!

Best regards,
Fredo