cancel
Showing results for 
Search instead for 
Did you mean: 

How to use 'HistoricTaskInstance.getTaskLocalVariables'

tamutamu
Champ in-the-making
Champ in-the-making
Hi,

In Activiti v5.13, I can't task local values using "HistoricTaskInstance.getTaskLocalVariables()".


  HistoricTaskInstance histTask =  historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();
  Map<String, Object> locValues = histTask.getTaskLocalVariables(); // locValues is Empty!!


In HistoricTaskInstanceEntity.getTaskLocalVariables(), it seems that "queryVariables" is null.
Why?

thanks for help.
4 REPLIES 4

aitor
Champ in-the-making
Champ in-the-making
Hi tamutamu,

It depends on whether the variables are saved with <code>task.setVariable()</code> or <code>task.setVariableLocal()</code>
Maybe this post can help you. It's about the scope of variables:

http://forums.activiti.org/content/does-taskvariablevalueequals-method-does-not-work

tamutamu
Champ in-the-making
Champ in-the-making
Thanks aitor!

I read that post.
But, I have not obtain the expected results.

Does'nt <code>Task</code> interface have <code>setVariable()</code> and <code>setVariableLocal()</code>?
<code>TaskService</code> interface has <code>setVariable()</code> and <code>setVariableLocal()</code>.

Since <code>HistoryService</code> also does'nt have <code>setVariable()</code> and <code>setVariableLocal()</code>, I tried to use <code>TaksService.setVariableLocal()</code>.
Below Code,
<java>
 Map<String, Object> inVarMap = new HashMap<String, Object>();
 inVarMap.put("VAL", "val");
 taskService.setVariablesLocal(taskId, inVarMap);

 Map<String, Object> outVarMap =
     taskService.createTaskQuery().taskId(taskId).singleResult().getTaskLocalVariables();  // But outVarMap is Empty!!
</java>

However it does not work.
Is This Code wrong?

After run the above code,  <code>VAL</code> value is stored in Table <code>ACT_RU_VARIABLE</code>, and the value of <code>Task_ID_</code> field is exist.

Thank you for your advice.

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi tamutamu.

I don't want to ask you silly questions. The can be many reasons (is History turned on, did you use historyService.createHistoricTaskInstanceQuery().includeTaskLocalVariables() …..?) The best way could be to create jUnit test.
http://forums.activiti.org/content/sticky-how-write-unit-test


tamutamu
Champ in-the-making
Champ in-the-making
Thanks martin.grofcik!
Explanation is insufficient, and I'm sorry.

I found the cause.
I didn't use <code>includeTaskLocalVariables</code>.

<code>HistoricTaskInstance.getTaskLocalVariables</code> javadoc「if requested 」, it is to call includeTaskLocalVariables in task query, isn't it. I wasn't able to notice that.

Thanks and best regards.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.