1

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

Sezer Aydın
  • 187
  • 1
  • 2
  • 10

2 Answers2

1

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

pme
  • 14,156
  • 3
  • 52
  • 95
  • `name` is not label. `name` is task form field id. for that we have to call one more rest-API to get the label. **Or name and Id must be the same**. – Sezer Aydın Mar 08 '22 at 19:38
0

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"
  }
]
rob2universe
  • 7,059
  • 39
  • 54