How to complete a User Task in a process?

1.3k Views Asked by At

I'm using flowable and I have this process: enter image description here

I would like to know, how can I programatically end Task A and then invoke Task B? Is there a way to do that?

P.S. Sorry, very new to using Flowable!

2

There are 2 best solutions below

0
On

In order to programatically complete a task in Flowable you can use the TaskService.

You can query for a task using the TaskQuery through TaskService#createTaskQuery and then use TaskService#complete(taskId, variables)

e.g.

Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).taskName("Task A").singleResult();


Map<String, Object> variables = new HashMap<>();
taskService.complete(task.getId(), variables);

task = taskService.createTaskQuery().processInstanceId(processInstanceId).taskName("Task B").singleResult();


variables = new HashMap<>();
taskService.complete(task.getId(), variables);
0
On

If you embed flowable engine in your spring boot, you will use flowable SDK to update status (see Filip's reply)

If you deploy flowable as standalone server, you will use REST API to update status (See horelvis' reply)