How to get taskid after the complete method

I have a workflow like: startevent -> task1(Assignee:Tom) -> choose sequence flow "agree" ->task2(Assignee:Jerry) -> choose sequence flow "disagree" -> task1

When the flow arrive to task1, i want to set assignee to "Tom" again.

Now i have an idea like:

When the flow arrive to task1, i use complete method, after the complete method, set a local variable "pre_task_id(task1's taskid)" in task2 so that i can use task1's taskid to search in "act_hi_taskinst" table for assignee(Tom), but this method taskService.setVariableLocal(taskId, variableName, value) need task2's taskid, how can i get the task2's taskid after complete method?

@Test
public void testCompleteTask() {
    Task task = taskService.createTaskQuery().taskAssignee("Tom").singleResult();
    if (task == null) {
        System.out.println("no task!!!");
        return;
    }
    String preTaskId = task.getId();
    HashMap <String,Object> variables = new HashMap<>();
    variables.put("userId", "Jerry");
    variables.put("oper", "saolu");
    taskService.complete(task.getId(),variables);
    //don't konw how to get the taskId 
    //taskService.setVariableLocal(taskId, "pre_task_id", preTaskId);
}

I am using activiti6

Or please let me konw if there are any better solutions

workflow.png



Read more here: https://stackoverflow.com/questions/66278503/how-to-get-taskid-after-the-complete-method

Content Attribution

This content was originally published by coooooong at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: