How to delete Activity History but keeping processInstance's History?

Hi guys,

We want to keep the processInstance history and also variables history for our finished processInstances, but we’d like to delete tasks and activities history.

So far I’ve found just historyService.deleteHistoricTaskInstance(task.getId()), which works fine, but I can’t find an equivalent method for removing activities history…

Could you please tell me how can I delete Activity History for a given processInstanceId by using your API?

Thanks in advance.

PS: I’ve successfully used historyService.deleteHistoricProcessInstance(processInstanceId), which deletes everything, but as I said I need to keep activity and variables history.

@alfmateos, I hope this might help you.

        .sql("DELETE * FROM ACT_HI_ACTINST where processDefinitionKey='someKey'");

Thanks a lot, aravindhrs,

But isn’t it a little bit dangerous to issue a native sql query? Is there another equivalent way to do it without using SQL? I’m worried about the possibility of leaving database inconsistencies…

Thanks in advance,

If you want to delete activity instance alone, native queries is the only way. Otherwise use java api of historical process instance deletion. Java or rest API not available to delete directly the historic activity instance.

Thanks a lot, aravindhs!