Get form key from historic task

人盡茶涼 提交于 2019-12-11 13:55:39

问题


We get the form key from task service likes following snipped code

for (Task task : getTaskService().createTaskQuery().taskCandidateGroupIn(candidateGroup).initializeFormKeys().list()) {

task.getFormKey()
....
....
...

}

but now for some special reason we wanna get the form key value from HistoricTaskInstance, and we try several ways to get it but all of them fail.

We are wondering that how we can get the form key value from completed task?


回答1:


The form key is not available for historic tasks. Usually forms are not displayed for historic tasks since the tasks have been completed. If the task has not been completed (history contains both active and completed tasks), then you can use the id of the historic task to get the form key using the form service.

If the task has already been completed, then you need to use the model api to get the form key from the XML:

HistoricTaskInstance historicTask = historyService.createHistoricTaskInstanceQuery().singleResult();

BpmnModelInstance bpmnModelInstance = repositoryService.getBpmnModelInstance(historicTask.getProcessDefinitionId());

org.camunda.bpm.model.bpmn.instance.Task task = bpmnModelInstance.getModelElementById(historicTask.getTaskDefinitionKey());
String formKey = task.getAttributeValueNs(BpmnModelConstants.CAMUNDA_NS, "formKey");


来源:https://stackoverflow.com/questions/28174298/get-form-key-from-historic-task

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!