How to get complete variables of a complete task
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2015 03:48 AM
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.
how can i get the finishedAmount with value 40 setted in taskService.complete()?
thanks a lot.
here is the sample code.
//1. create a taskTask task = taskSrv.newTask();task.setName("test execution");task.setOwner(user1.getId());task.setAssignee(user2.getId());taskSrv.saveTask(task);//2. set task variablesMap<String, Object> taskVariables = new HashMap<String, Object>();taskVariables.put("finishedAmount", 0);taskSrv.setVariables(task.getId(), taskVariables);//3. complete this task with a new variableMap<String, Object> finishVariables = new HashMap<String, Object>();finishVariables.put("finishedAmount", 40);taskSrv.complete(user2Tasks.get(0).getId(), finishVariables);//4. get completed variableList<HistoricVariableInstance> hisVarList = historyService.createHistoricVariableInstanceQuery().taskId(hisTaskList.get(0).getId()).list();System.out.println(hisVarList); // here only get varibale finshedAmount = 0List<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.
Labels:
- Labels:
-
Archive
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2015 06:58 AM
It seems you have hit a bug in Activiti. I ported your test and fixed it on the current master branch: https://github.com/Activiti/Activiti/commit/2e9cfb7cf7cdfe832a1eab4f4afaab8f30644805
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2015 09:11 PM
thank you for quick reply. 🙂
there is another small question. when i can't get complete variables, i tried setVariables before complete the task.
so, is there any difference between the two approachs?
<java>
Map<String, Object> finishVariables = new HashMap<String, Object>();
finishVariables.put("finishedAmount", 40);
taskSrv.complete(task.getId(), finishVariables);
</java>
<java>
Map<String, Object> finishVariables = new HashMap<String, Object>();
finishVariables.put("finishedAmount", 40);
taskSrv.setVariables(task.getId(), finishVariables);
taskSrv.complete(task.getId());
</java>
there is another small question. when i can't get complete variables, i tried setVariables before complete the task.
so, is there any difference between the two approachs?
<java>
Map<String, Object> finishVariables = new HashMap<String, Object>();
finishVariables.put("finishedAmount", 40);
taskSrv.complete(task.getId(), finishVariables);
</java>
<java>
Map<String, Object> finishVariables = new HashMap<String, Object>();
finishVariables.put("finishedAmount", 40);
taskSrv.setVariables(task.getId(), finishVariables);
taskSrv.complete(task.getId());
</java>
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2015 05:07 AM
Not functionally.
Technically, the first one will be one database transaction, second one will be two database transactions.
Technically, the first one will be one database transaction, second one will be two database transactions.
