Is there an API that shows the user task histroy on the Camunda side?

Viewed 270

I have a Camunda flow, there are 2-3 user tasks in this flow. I want to see their history after completing these tasks. There are a couple of methods, but I just want to get both the label and the entered value with rest-api.

I can't get them directly with rest-api.

The following method returns variables with the processInstanceId.

List<HistoricVariableInstance> instances = historyService.createHistoricVariableInstanceQuery()
.processInstanceId(processIntanceId)
.list();

but I need to call another rest-api to get the labels. GET /process-definition/{id}/xml with this api.

Other topics have been opened for this, but it does not meet exactly what I want. similar question

2 Answers

I think you are right, you need 2 steps. I would combine the following requests:

First get all User Tasks:

GET /history/task -see API Reference

From its result Array you need the id and the name (which is the label):

[{"id":"anId",
 ...
 "name":"aName",
 ...
 }]

Now you can get the variables for each UserTask, like

GET /history/variable-instance?taskIdIn=YourTaskId see API Reference

https://docs.camunda.org/manual/7.16/reference/rest/history/variable-instance/post-variable-instance-query/

returns the name (label) and the value of the process variables

[
  {
    "id": "someId",
    "name": "someVariable",
    "type": "Integer",
    "variableType": "integer",
    "value": 5,
    "valueInfo": {},
    "processDefinitionKey": "aProcessDefinitionKey",
    "processDefinitionId": "aProcessDefinitionId",
    "processInstanceId": "aProcInstId",
    "executionId": "aExecutionId",
    "activityInstanceId": "aActivityInstId",
    "caseDefinitionKey": null,
    "caseDefinitionId": null,
    "caseInstanceId": null,
    "caseExecutionId": null,
    "taskId": null,
    "tenantId": null,
    "errorMessage": null,
    "state": "CREATED",
    "createTime":"2017-02-10T14:33:19.000+0200",
    "removalTime": "2018-02-10T14:33:19.000+0200",
    "rootProcessInstanceId": "aRootProcessInstanceId"
  }
]
Related