question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ProcessInstanceQuery・HistoricProcessInstanceQuery's queryVariableValues should be used to target only the global scope variables?

See original GitHub issue

ProcessInstanceQuery・HistoricProcessInstanceQuery’s queryVariableValues should be used to target only the global scope variables? Which is correct, the specifications of javadoc or the actual source code?

Correct behavior

We think ProcessInstanceQuery・HistoricProcessInstanceQuery’s queryVariableValues should be used to target only the global scope variables. This specification is written in the following javadoc.

And, because ProcessInstanceQuery・HistoricProcessInstanceQuery’s return only the global scope variables(includeProcessVariables flag), the search criteria specification also should target only the global scope variables.

Actual behavior

But, ProcessInstanceQuery・HistoricProcessInstanceQuery’s queryVariableValues can be used to target the execution scope and task scope variables,too.

<foreach collection="queryVariableValues" index="index" item="queryVariableValue">
  inner join ${prefix}ACT_HI_VARINST  A${index} on RES.PROC_INST_ID_ = A${index}.PROC_INST_ID_
</foreach>

We thought this behavior was bug,but the test case(HistoryServiceTest.testHistoricVariableInstancesOnParallelExecution) guarantees this behavior.

List<Task> tasks = taskService.createTaskQuery().processInstanceId(pi.getId()).list();
for (Task task : tasks) {      
  Map<String, Object> variables = new HashMap<String, Object>();
  // set token local variable
  log.debug("setting variables on task {}, execution {}", task.getId(), task.getExecutionId());
  runtimeService.setVariableLocal(task.getExecutionId(), "parallelValue1", task.getName());
  runtimeService.setVariableLocal(task.getExecutionId(), "parallelValue2", "test");
  taskService.complete(task.getId(), variables);      
}
taskService.complete(taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult().getId());

assertEquals(1, historyService.createHistoricProcessInstanceQuery().variableValueEquals("rootValue", "test").count());

assertEquals(1, historyService.createHistoricProcessInstanceQuery().variableValueEquals("parallelValue1", "Receive Payment").count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().variableValueEquals("parallelValue1", "Ship Order").count());
assertEquals(1, historyService.createHistoricProcessInstanceQuery().variableValueEquals("parallelValue2", "test").count());

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
jbarrezcommented, Jun 16, 2016

I see and understand your point. It’s indeed not consistent. But I’m also weary of breaking code for users that currently depend on the inconsistent behavior.

What concrete use case are you trying to fix with this?

0reactions
salaboycommented, Nov 22, 2017

I’m closing this due to inactivity for more than a year. Please reopen if this is an issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Global vs. Local Variables - Code.org Tool Documentation
Debugging Variable Scope: Functions. Create Variables Once, At the Top, Outside Functions or onEvent(). When you create variables you should: Use var only ......
Read more >
Using global variables in a function - Stack Overflow
You can use a global variable within other functions by declaring it as global within each function that assigns a value to it:...
Read more >
HistoricProcessInstanceQuery (camunda BPM Javadocs 7.2 ...
Only select process instances which has a global variable value less than or equal to the passed value when they ended. HistoricProcessInstanceQuery ...
Read more >
Comparing the effect of global scope - AWS Lambda
Private data that is only used per invocation should be defined within the handler. Global variables retain their value between invocations in the...
Read more >
How do I make a variable accessibl… | Apple Developer Forums
I need a variable that will be accessible from my main target, and an imported ... A Global Variable doesn't work as it's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found