How to create subtask/ checklist task?

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
bakde_naveen
Member II

How to create subtask/ checklist task?

Jump to solution

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 Solution

Accepted Solutions
gdharley
Intermediate

Re: How to create subtask/ checklist task?

Jump 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

3 Replies
gdharley
Intermediate

Re: How to create subtask/ checklist task?

Jump 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

bakde_naveen
Member II

Re: How to create subtask/ checklist task?

Jump to solution

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. 

gdharley
Intermediate

Re: How to create subtask/ checklist task?

Jump to solution

The code I provided successfully creates a subtask, did you try it?