Why is TASK_ID_ column always null in act_hi_detail table?

Hi,
We are trying to fetch process variables corresponding to process instance id and task id using GET /history/detail but in taskId is always null in the response. We also checked the Camunda database and TASK_ID_ column is always null in act_hi_detail table.

Could you please specify the reason behind the null entry?

Our main purpose is ti fetch the process variables for a completed task, so also please suggest the rest api call for the same in which using unique processInstanceId and unique taskId generated at run time, we could fetch the process variables that got updated in that particular task.

Hi @AakankshaTej,

This field is only populated when the variable is defined in the scope of a task instance, i.e. it is a task-local variable. Typically (also when you complete a task), variables are created in a higher scope, for example the process instance execution. See the following link for more on variable scopes: https://docs.camunda.org/manual/7.9/user-guide/process-engine/variables/#variable-scopes-and-variable-visibility

In order to identify to which task a variable update belongs, you can use the field activityInstanceId of a historic detail, which corresponds to the id when you fetch historic activity instances.

Cheers,
Thorben

1 Like