cancel
Showing results for 
Search instead for 
Did you mean: 

[Java] Get task id after workflow start

axl8713
Champ on-the-rise
Champ on-the-rise
Hi everybody!

I'm trying to develop a Java backed webscript that starts a new workflow and redirects the user to the 'task-edit' page for the first 'userTask'.

In the method
executeImpl
, I start a new workflow and subsequently end the start task. Now the active task should be the one following the start task, so I query for it:

WorkflowTaskQuery query = new WorkflowTaskQuery();
query.setActive(null);
query.setWorkflowDefinitionName("activiti$cdGroupMeeting");
query.setTaskState(WorkflowTaskState.IN_PROGRESS);
List<WorkflowTask> tasks = serviceRegistry.getWorkflowService().queryTasks(query, true);

The list
tasks
is empty. What's wrong?

Moreover, if I redirect the user on another webscript and execute the query from there, it works.

Someone could explain me this behaviour? There's another way to accomplish my need?

Thanks,
Alessandro
4 REPLIES 4

axl8713
Champ on-the-rise
Champ on-the-rise
Maybe is too early to query for the first task right after the start task end.
Alfresco (or Activiti) might need some time to update workflow data…

Any thoughts?

axl8713
Champ on-the-rise
Champ on-the-rise
Nobody have had the same problem?

kaynezhang
World-Class Innovator
World-Class Innovator
Try
 
org.alfresco.service.cmr.workflow.WorkflowService.getStartTask(String workflowInstanceId);

method

sawa
Champ in-the-making
Champ in-the-making
Any ideas.
Me too i need to start from the task after the start task. how can i do that
Than you for your help