cancel
Showing results for 
Search instead for 
Did you mean: 

Evaluation of Completion Condition variable

nicodio
Champ in-the-making
Champ in-the-making

Hi, I've got a workflow with a Sequential Multi Instance call to activiti.

In the called workflow I've got a variable used in gateways (lodgeSubmissions) and I want to use this variable in the Complete condition but it does not seems to work. If I put "lodgeSumbissions.equals("false")" in the complete condition activiti tells that cannot evaluate it, if I get it via execution.getVariable("lodgeSubmissions") it does seem to be present as an execution.

I read the user guide that has an example but does not explain how to obtain the variable in that condition.

What am I doing wrong?

EDIT: from another reading of the user guide it seems that only certain variables can be used there (nrOfCompletedInstances, nrOfActiveInstances, nrOfInstances) but with those I cannot use something that happens in the other subworkflows. Is that correct?

Thank you

4 REPLIES 4

abbask01
Star Collaborator
Star Collaborator

for conditions in activiti, you'll have to use expressions (UEL) instead of code snippets. e.g. if lodgeSubmissions is the variable you are trying to monitor on each task inside your multi-instance then the completion condition would be ${!lodgeSubmissions} or ${lodgeSubmissions == false}

The reason why you don't get the variable is because of the variable scope being local to the task inside multi-instance.

Hope it helps.

Regards,
Abbas

nicodio
Champ in-the-making
Champ in-the-making

Hi, Abbas, thanks for the answer.

I'm using the variable inside the gateways in the sub task and it works as expected. But if I use it in the completion condition (eg ${lodgeSubmissions.equals("false")}) of the container I get this error

org.activiti.engine.ActivitiException: Unknown property used in expression: ${lodgeSubmissions.equals("true")}
[...]
Caused by: org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'lodgeSubmissions'

So my doubt is that I cannot do what I want to accomplish because the only variables that can be used inside the completion condition of a multi instance are only these three nrOfCompletedInstances, nrOfActiveInstances, nrOfInstances. Is that correct?

abbask01
Star Collaborator
Star Collaborator

Basically all variables (under the process scope) can be used inside completion condition. As i mentioned earlier, you cannot access your variables because of their local scope inside the sub-process. you can use execution listener to set the variable explicitly

(execution.setVariable...)

the listener would run for each instance of the task, and the variable set can then be used inside the completion condition.

Regards,
Abbas

sairaarif
Champ in-the-making
Champ in-the-making

Please share example with bpmn and code