0

Currently i have a process Start -> Subprocess start-> usertask1 -> usertask2 -> end.

So the process is started with a list of id's for each id we create a subprocess with start -> usertask1 ->usertask2 ->end. usertask1 can be assigned to Candidategroup A and B usertask2 can be assinged to Candidategroup B

Now in my use case if a user of candidategroup B gets usertask1 he cannot get usertask2. How to achieve this?

My work till now.

Added a expression on assignment of usertask2

and used

   taskService.createTaskQuery().processDefinitionId(delegateTask.getProcessDefinitionId()).orderByTaskCreateTime().asc().list()

But this gives all the task within the process not the subprocess.

I even has history service. I can get the tasks of the process but i want only of the subprocess.

please advice

Learner
  • 237
  • 4
  • 15

1 Answers1

0

If your subprocess has a process definition key then you could try doing a query by .processDefinitionKey in instead of processDefinitionId. For an example you can see it set at https://github.com/Activiti/Activiti/blob/develop/activiti-engine/src/test/resources/org/activiti/engine/test/api/task/TaskQueryTest.testProcessDefinition.bpmn20.xml#L7 and used in https://github.com/Activiti/Activiti/blob/126e89911d49c6ec0ab3f222baeea2a256e24c0d/activiti-engine/src/test/java/org/activiti/engine/test/api/task/TaskQueryTest.java#L1874

Or if you're really interested in a particular task or set of tasks then you could give those tasks names and query for tasks matching that name (https://community.alfresco.com/thread/223377-throws-exception-taskservicecreatetaskquerytaskname) or names (in which case it's taskNameIn).

You could also set a variable on the process instance during the execution of task1 and use the value of that variable in your query. For example you could set a variable called 'actionedTask1' and record the id of the user who actioned task1. Then I think you could query for processVariableValueNotEquals("actionedTask1", user id) to find tasks that weren't actioned by the current user.

Another point to note is that you have access to the DelegateTask so you can go from there to the DelegateExecution and from there you should be able to get the ids of the process instance and the parent process instance. You could then use the runTimeService to query for an instance and use that to get the ProcessDefinition that an instance belongs to. But I'm not sure if your main problem is really about the subprocess or about the task assignment. If it's about the task assignment and querying as I suggested doesn't fit then you can look at Dynamically setting user task assignee

Ryan Dawson
  • 11,832
  • 5
  • 38
  • 61