Dynamically assigning task to users
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2013 02:27 PM
Activiti Version: 5.12.
We have a need, for an admin to view all user tasks under a bpmn model file and assign each task to suitable user. For this we have created an admin task. Please note, when admin person assigns tasks to users, tasks are not yet executed(i.e kind of future tasks). After admin complete his job, each user should login to their UI screen and compelte task. We have our own UI framework for Admin and user pages.
Q: how to allow the admin person to assign the future tasks ?
Following code snippet is used to query all tasks
String processDefinitionID = rtService
.createProcessInstanceQuery().list().get(0).getProcessDefinitionId();
BpmnModel bpmnmodel = reposService.getBpmnModel(processDefinitionID);
List<Process> processes = bpmnmodel.getProcesses();
for(Process indivProcess
rocesses){
List<UserTask> userTasks = indivProcess.findFlowElementsOfType(UserTask.class);
for(UserTask userTask:userTasks){
System.out.println("Task=" + userTask.getName() + "; TaskAssignee=" + userTask.getAssignee()+"\n");
}
}
however userTask.setAssignee(userName); does not see to work.
Kindly suggest.
Thanks
Sambit
We have a need, for an admin to view all user tasks under a bpmn model file and assign each task to suitable user. For this we have created an admin task. Please note, when admin person assigns tasks to users, tasks are not yet executed(i.e kind of future tasks). After admin complete his job, each user should login to their UI screen and compelte task. We have our own UI framework for Admin and user pages.
Q: how to allow the admin person to assign the future tasks ?
Following code snippet is used to query all tasks
String processDefinitionID = rtService
.createProcessInstanceQuery().list().get(0).getProcessDefinitionId();
BpmnModel bpmnmodel = reposService.getBpmnModel(processDefinitionID);
List<Process> processes = bpmnmodel.getProcesses();
for(Process indivProcess

List<UserTask> userTasks = indivProcess.findFlowElementsOfType(UserTask.class);
for(UserTask userTask:userTasks){
System.out.println("Task=" + userTask.getName() + "; TaskAssignee=" + userTask.getAssignee()+"\n");
}
}
however userTask.setAssignee(userName); does not see to work.
Kindly suggest.
Thanks
Sambit
Labels:
- Labels:
-
Archive
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2013 05:00 AM
You should either use:
taskService.setTaskAssignee(…)
or use:
task.setAssignee(…);
taskService.saveTask(task.getId());
taskService.setTaskAssignee(…)
or use:
task.setAssignee(…);
taskService.saveTask(task.getId());
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2013 11:31 AM
Does
"taskService.setTaskAssignee(…)
or use:
task.setAssignee(…);
taskService.saveTask(task.getId());"
work for the assigning the tasks which are not yet executed in the flow ? I mean activiti wont have generated taskIds by the time user assignments are being performed.
So if the flow looks like this
X–(user task1)—(user task2)—(user task3)—()
before starting the process the admin should be able to see all list of tasks and assigning to users.
"taskService.setTaskAssignee(…)
or use:
task.setAssignee(…);
taskService.saveTask(task.getId());"
work for the assigning the tasks which are not yet executed in the flow ? I mean activiti wont have generated taskIds by the time user assignments are being performed.
So if the flow looks like this
X–(user task1)—(user task2)—(user task3)—()
before starting the process the admin should be able to see all list of tasks and assigning to users.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2013 11:41 AM
Before starting the process you only have the process definition available, because there's no process instance yet. So for your use case it would make sense to get the BpmnModel and show the list of tasks. Then when the user has chosen the assignees you can pass them to the process instance as process variables.
Best regards,
Best regards,
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2013 12:33 PM
Thanks for the advise.
Pls suggestion how should I access the process variable? I am aiming to access them via expression on UserTask.
Thanks
Sambit
Pls suggestion how should I access the process variable? I am aiming to access them via expression on UserTask.
Thanks
Sambit
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2013 05:15 AM
That's all in the docs … typically just do ${myVariable}
