How to create subtask/ checklist task immediately after creating task(parent)? I tried with taskListener but it is not helping as the task creation is not completed and record has not inserted into the database. Please help...
Solved! Go to Solution.
Naveen,
I created a simple TaskListener with the following code:
public void notify(DelegateTask delegateTask) {
getLogger().debug("In TaskListener for task {}", delegateTask.getEventName());
TaskService taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
Task newTask = taskService.newTask();
newTask.setParentTaskId(delegateTask.getId());
newTask.setName("MySubTask");
newTask.setAssignee(delegateTask.getAssignee());
newTask.setTenantId(delegateTask.getTenantId());
taskService.saveTask(newTask);
}
I assigned this to the "create" event for a User task and it successfully created a sub task:
Notice the checklist task.....
Let me know if this doesn't satisfy your requirement.
Greg
Naveen,
I created a simple TaskListener with the following code:
public void notify(DelegateTask delegateTask) {
getLogger().debug("In TaskListener for task {}", delegateTask.getEventName());
TaskService taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
Task newTask = taskService.newTask();
newTask.setParentTaskId(delegateTask.getId());
newTask.setName("MySubTask");
newTask.setAssignee(delegateTask.getAssignee());
newTask.setTenantId(delegateTask.getTenantId());
taskService.saveTask(newTask);
}
I assigned this to the "create" event for a User task and it successfully created a sub task:
Notice the checklist task.....
Let me know if this doesn't satisfy your requirement.
Greg
Thanks Greg for the quick reply. Alfresco has provided checklist service (AlfrescoChecklistService.addSubtask) to create checklist task. I want to use this service to create checklist sub-task. Internally this service querying to the DB for parent task which is failing for me. Is there any way to create checklist task immediately after parent task has been created.
The code I provided successfully creates a subtask, did you try it?
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.