AnsweredAssumed Answered

How to get complete variables of a complete task

Question asked by smartxiaofish on Jun 12, 2015
Latest reply on Jun 16, 2015 by jbarrez
hi, i'm trying to create a new task, with variables, and complete it with variables update,  and i can't get variables setted in complete call.

here is the sample code.

//1. create a task
Task task = taskSrv.newTask();
task.setName("test execution");
task.setOwner(user1.getId());
task.setAssignee(user2.getId());
taskSrv.saveTask(task);

//2. set task variables
Map<String, Object> taskVariables = new HashMap<String, Object>();
taskVariables.put("finishedAmount", 0);
taskSrv.setVariables(task.getId(), taskVariables);


//3. complete this task with a new variable
Map<String, Object> finishVariables = new HashMap<String, Object>();
finishVariables.put("finishedAmount", 40);
taskSrv.complete(user2Tasks.get(0).getId(), finishVariables);

//4. get completed variable
List<HistoricVariableInstance> hisVarList = historyService.createHistoricVariableInstanceQuery().taskId(hisTaskList.get(0).getId()).list();
System.out.println(hisVarList);  // here only get varibale finshedAmount = 0

List<HistoricDetail> hisDetailList = historySrv.createHistoricDetailQuery().variableUpdates().taskId(hisTaskList.get(0).getId()).list();
System.out.println(hisDetailList); // and I tried historicDetailQuery, there is no results.

how can i get the finishedAmount with value 40 setted in taskService.complete()?

thanks a lot.

Outcomes