Process instance - task level start and end time

I know we can get the details like start time, end time and duration of a process instance. We are now looking at ways to record the time at the task level. Is there a way we can do this?

Yes you can get details at task level as well
Please find below RestAPI with query parameters -createdOn,createdOnExpression,createdAfter,createdAfterExpression or createdBefore

https://docs.camunda.org/manual/7.12/reference/rest/task/get-query/

You can use either of parameters to fetch task list

@deepu.v87 Camunda GET /task or POST /task apis will not return task completion time, it has only creation time. Below is sample response:

[{"id":"anId",
 "name":"aName",
 "assignee":"anAssignee",
 "created":"2013-01-23T13:42:42.657+0200",
 "due":"2013-01-23T13:49:42.323+0200",
 "followUp:":"2013-01-23T13:44:42.987+0200",
 "delegationState":"RESOLVED",
 "description":"aDescription",
 "executionId":"anExecution",
 "owner":"anOwner",
 "parentTaskId":"aParentId",
 "priority":42,
 "processDefinitionId":"aProcDefId",
 "processInstanceId":"aProcInstId",
 "caseDefinitionId":"aCaseDefId",
 "caseInstanceId":"aCaseInstId",
 "caseExecutionId":"aCaseExecution",
 "taskDefinitionKey":"aTaskDefinitionKey",
 "suspended": false,
 "formKey":"aFormKey",
 "tenantId": "aTenantId" }]

So you can write a native queries to find the task creation & completion time.

select ID_, NAME_, START_TIME_, END_TIME_, DURATION_ from act_hi_taskinst where 
PROC_DEF_KEY_='scheduledProcess' and TENANT_ID_='robo3t' and 
PROC_INST_ID_='0632bc9c-8087-11ea-9dcb-507b9dc4ed46'; 

This table is empty for me. Do we need to make any configuration so that the details are captured?

History is set to “full” at the engine configuration.

if task is in active state means then it will only give createdtime …
if need to fetch duration start and end task even then task details should fetch from history table

GET /history/task?taskAssignee=anAssignee&priority=42

{"id":"anId",
 "processDefinitionId":"aProcDefId",
 "processInstanceId":"aProcInstId",
 "executionId":"anExecution",
 "caseDefinitionId":"aCaseDefId",
 "caseInstanceId":"aCaseInstId",
 "caseExecutionId":"aCaseExecution",
 "activityInstanceId": "anActInstId",
 "name":"aName",
 "description":"aDescription",
 "deleteReason": "aDeleteReason",
 "owner":"anOwner",
 "assignee":"anAssignee",
 > **"startTime":"2013-01-23T13:42:42.000+0200",**
> ** "endTime":"2013-01-23T13:45:42.000+0200",**
> ** "duration": 2000,**
 "taskDefinitionKey":"aTaskDefinitionKey",
 "priority":42,
 "due":"2013-01-23T13:49:42.000+0200",
 "parentTaskId":"aParentId",
 "followUp:":"2013-01-23T13:44:42.000+0200",
 "tenantId":null,
 "removalTime": "2018-02-10T14:33:19.000+0200",
 "rootProcessInstanceId": "aRootProcessInstanceId"
 }]

I do see data in table “act_hi_actinst”. Is this reliable?
We also have external tasks in our workflows. The time for the execution of those tasks includes the wait time at the worker side as well?

Hi Deepika

Every task is associate with process instance Id with process instance id you can check the data in act_hi_actinst is associate with your process instance id or not?

task will persist in act_hi_actinst only after completion of task

@deepu.v87 Yes data is reliable.

For every transaction/update data will be persisted in history tables also. You can verify by adding or changing few task properties from tasklist webapps.