I have a sequential multi-instance service task in Camunda Modeler that iterates over a collection variable. The configuration is as follows:
Collection: ${auditDocIds}
Element Variable: auditDocId
Within the same service task, I am trying to use the auditDocId variable in an input parameter expression, like this:
document/${auditDocId}/content
However, when the service task executes, it throws the following error:
Unknown property used in expression: document/${auditDocId}/content.
Cause: Cannot resolve identifier 'auditDocId'
My Understanding:
I expected auditDocId to be available as a local variable for each iteration of the multi-instance service task. However, it seems like the variable isn’t being resolved correctly when used directly in the input parameter of the service task.
Unfortunately, the variables created from each are defined in two separate scopes. Variables generated from input parameters exist in a higher-level scope than the element variables, which prevents input parameter variables from accessing the element variables.
To overcome this, you can use an embedded sub-process as a container for the service task and mark it as a multi-instance. This way element variables are created in the higher-scope and should be accessible from input parameters defined on the inner service task.
Hi @hassang thank you for your response. Initially, I implemented it the way you demonstrated. However, I noticed that my multi-instance setup was only working with a single service task. I later discovered a way to add multi-instance functionality directly to the service task itself, which appears clearer and more concise. Unfortunately, it’s disappointing that I can’t use it that way.