Rest task complete workflow


#1

Hey,

I have a problem with the rest api. I do not understand how I get a correct workflow with rest. After I start my process how I get the ID of the task? With the information from process start I do not get it.Am actually looking at all tasks and search the task with the executionId.

Here are the respondes from my way.

Start process
{
“links”:[
{
“method”:“GET”,
“href”:“http://localhost:8080/engine-rest/process-instance/e0d47a60-458c-11e9-9665-787b8abcf0fa”,
“rel”:“self”
}
],
“id”:“e0d47a60-458c-11e9-9665-787b8abcf0fa”,
“definitionId”:“Testdurchlauf:1:86c0a20f-458c-11e9-9665-787b8abcf0fa”,
“businessKey”:null,
“caseInstanceId”:null,
“ended”:false,
“suspended”:false,
“tenantId”:null
}

Get Tasks
{
“id”:“e0d47a63-458c-11e9-9665-787b8abcf0fa”,
“name”:"Round 1 ",
“assignee”:“demo”,
“created”:“2019-03-13T13:38:18.127+0100”,
“due”:null,
“followUp”:null,
“delegationState”:null,
“description”:null,
“executionId”:“e0d47a60-458c-11e9-9665-787b8abcf0fa”,
“owner”:null,
“parentTaskId”:null,
“priority”:50,
“processDefinitionId”:“Testdurchlauf:1:86c0a20f-458c-11e9-9665-787b8abcf0fa”,
“processInstanceId”:“e0d47a60-458c-11e9-9665-787b8abcf0fa”,
“taskDefinitionKey”:“Task_0wmu3bx”,
“caseExecutionId”:null,
“caseInstanceId”:null,
“caseDefinitionId”:null,
“suspended”:false,
“formKey”:null,
“tenantId”:null
}

Round 2
{
“id”:“ee760d4e-458d-11e9-9665-787b8abcf0fa”,
“name”:“Round 2”,
“assignee”:“demo”,
“created”:“2019-03-13T13:45:50.493+0100”,
“due”:null,
“followUp”:null,
“delegationState”:null,
“description”:null,
“executionId”:“e0d47a60-458c-11e9-9665-787b8abcf0fa”,
“owner”:null,
“parentTaskId”:null,
“priority”:50,
“processDefinitionId”:“Testdurchlauf:1:86c0a20f-458c-11e9-9665-787b8abcf0fa”,
“processInstanceId”:“e0d47a60-458c-11e9-9665-787b8abcf0fa”,
“taskDefinitionKey”:“Task_1oqs7ya”,
“caseExecutionId”:null,
“caseInstanceId”:null,
“caseDefinitionId”:null,
“suspended”:false,
“formKey”:null,
“tenantId”:null
}

Hope there is a way which is mutch more practicable. Thanks in advance


#2

Hi @xAJ,

You can get the task id directly from the process instance by using the “withVariablesInReturn” API. [1]
To set the task id as process variable you can use a task listener. [2]

However, if you want to complete those tasks programmatically, I suggest you look into ExternalTask pattern which lets you long poll for any new external tasks to be completed by a client. [3]

[1] https://docs.camunda.org/manual/7.10/reference/rest/process-definition/post-start-process-instance/
[2] https://docs.camunda.org/manual/7.10/user-guide/process-engine/delegation-code/#task-listener
[3] https://docs.camunda.org/manual/7.10/user-guide/process-engine/external-tasks/


#3

With variant 1 I get a new field “variables” which is empty.

Variant 2 is Java stuff I only want to use the rest api.

“variables”: {}

I don´t know how this should help me :frowning:

For example why the rest api is not returning me the next task id when I complete the task. So i have to find it now by get all tasks.

Hope its now more clear what I want :smiley:


#4

Hey @xAJ,

You need to explicitly save the task id as a process variable. Did you specify a custom task listener? (see link #2) Your taskListener class should be called when the execution token arrives at the user task. In your task listeners implementation set the process variable. It could look like this:

public class SetProcessInstanceVariableListener implements TaskListener {
    @Override
    public void notify(DelegateTask delegateTask) {
    delegateTask.getProcessEngineServices().getRuntimeService().setVariable(delegateTask.getProcessInstanceId(), "myNextTaskId", delegateTask.getId());
    }
  }

Let me know if this helped you.

Cheers,
Miklas


#5

Hey,

Im sad to say that Java is no option for me sorry, only rest.
Is there any good example with a rest workflow create, complete task, complete the next task and so on?

My only Problem is that the response ist not helping me because there is no connection to the next task (so i have to do an addional step :frowning: ).

Or I don´t understand the workflow :smiley:


#6

Hi @xAJ,

maybe you can check out this REST Call. Maybe this can help you in your use case to get information about the tasks.

As mentioned here in the documentation this method is also used to show the information you need in the cockpit.

Hope this helps.

Regards
Michael


#7

Hi @Miklas,

I have a user task which contains a form with filled-in values from a previous multi-instance task.
What I want to achieve, is to save the task_id of this form as a process variable when the execution token arrives at this task and to get the html content of this form on the completion of this task, by making a REST Api call like this:
https://docs.camunda.org/manual/7.10/reference/rest/task/get-rendered-form/
I’ve decided to add 2 Task Listeners in this task (create and complete as Event Types respectively).

My question is which Listener Type is the most appropriate for my purpose ?
Could you please guide me a bit here please ?

Thanks in advance,
Steve


#8

Hi @steftriant,

I believe your question is not within the scope of the original question. Please open a seperate topic for it.

Cheers,
Miklas


#9

Hi @Miklas and thanks for your hint.

Ok, I opened a new post with this topic here in case you could suggest sth.

Thanks in advance,
Steve