01-10-2017 03:57 AM
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...
01-10-2017 10:42 AM
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
01-10-2017 10:42 AM
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
01-10-2017 10:22 PM
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.
01-11-2017 09:13 AM
The code I provided successfully creates a subtask, did you try it?
Explore our Alfresco products with the links below. Use labels to filter content by product module.