Hello!
I have been testing around the Multi-Instance for a Call Activity and in parallel and I am now facing troubles with using predefined variables in the completionCondition. I have tried loopCounter = 2
that works fine for the flow.
When I try anything with numberOfInstances, numberOfActiveInstances, numberOfCompletedInstances, numberOfTerminatedInstances, I get this kind of error:
failed to evaluate expression 'numberOfInstances = 2': no variable found for name 'numberOfInstances'
Am I missing something here to understand? Am I supposed to declare these variables somewhere?
It looks like there is no variable in the context with the name “numberOfInstances” available. Keep in mind that these are not “predefined” and available by default.
You would always need to have them explicitly available in the process instance.
Ah I see! I am using java for the Handler and Definition of processes. I did not know these weren’t predefined like loopCounter for example. Do I simply need to declare them to be able to use them? For example: public static final String WORKER_TYPE = "WORKER_NAME";
Or do I need to have a method for it?
So either you create this variable on startup at the process or you can create one during the runtime using a worker.
This would look something like this:
JobWorker(type = "foo")
public Map<String, Object> handleJobFoo(final ActivatedJob job) {
// some work
if (successful) {
// some data is returned to be stored as process variable
return variablesMap;
} else {
// problem shall be indicated to the process:
throw new ZeebeBpmnError("DOESNT_WORK", "This does not work because...");
}
}
Long story short: Either start the process with this value, or set it using a “worker” method.
Hopefully this was hepful to you!
Hmm that is interesting
I haven’t used these properties in my complete conditions yet.
Have you tried running the exact expression as in the docu once?
I tried this: numberOfCompletedInstances / numberOfInstances >= 0.5
and it did not give me an error but it also just went through every item in the collection and completed them. It didn’t terminate any of them.
Hi @creative I’d also be interested to see your process model (bpmn file). Did you happen to use these properties in the completionCondition expression, or in another place? And which version of camunda 8 are you using? These properties are introduced only to the completionCondition, and only since version 8.1.
We use Camunda Platform 8.0 So Maybe the version is the issue?
You’ll need to upgrade to version 8.1 to have access to the multi-instance properties in the completion condition expression. Please let me know if that solves your issue
You’ll also need to change Completion condition to numberOfCompletedInstances / numberOfInstances >= 0.5 to try this out. These properties are only available to the completion condition expression. They are not available as variables, nor as input/output mappings.