cancel
Showing results for 
Search instead for 
Did you mean: 

How to create subtask/ checklist task?

bakde_naveen
Champ in-the-making
Champ in-the-making

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...

1 ACCEPTED ANSWER

gdharley
Elite Collaborator
Elite Collaborator

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

View answer in original post

3 REPLIES 3

gdharley
Elite Collaborator
Elite Collaborator

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?

Getting started

Explore our Alfresco products with the links below. Use labels to filter content by product module.