When using “camunda:modelerTemplate” in the modeller, we obtain this bpmn snippet:
<bpmn:sendTask camunda:class="gdp.servicetasks.EmailTaskService" camunda:modelerTemplate="cat.dipta.actio.MailTask" completionQuantity="1" id="email" implementation="##WebService" isForCompensation="false" name="Email" startQuantity="1"><bpmn:extensionElements><camunda:inputOutput><camunda:inputParameter name="subject">message for ${user}</camunda:inputParameter>[...]
According to documentation (camunda docs), the contents of camunda:inputParameter
should be evaluated and available to class gdp.servicetasks.EmailTaskService
In our JavaDelegate class, we have:
public void execute(DelegateExecution ex) throws Exception {
println "SBJ: ${ex.getVariable('subject')}"
And we expected to get “SBJ: message for mabertran” because value of variable ‘user’ is mabertran.
Instead of this, we get the original “SBJ: message for ${user}” string.
We tried to declare field
Expression subject
And get the value by subject.getValue(ex)
but didn’t work.
The only way we could reach the desired result was by changing our bpmn:
<camunda:inputParameter name="subject"> <camunda:script scriptFormat="groovy">"message for ${user}"</camunda:script></camunda:inputParameter>
And then ${ex.getVariable('subject')}
made the evaluation of such script which evaluates to the desired string, but I’d like to avoid this solution because I don’t like to evaluate a variable (which my be assigned by a user) as a groovy script.
FINALLY:
Is a way to use <camunda:inputParameter>
in a similar as <camunda:field>
to evaluate expressions (described here)?
Which is the best solution to use field injection in combination with camunda:modelerTemplate which seems to force the use of <camunda:inputParameter>
?
UPDATE:
We tried <camunda:inputParameter>
with a content that is uniquely an expression (only content like: ${expression} and nothing else) and expression evaluation finally seems to work as expected. The only thing is that I need to evaluate something of the form: "message sent to ${user}"
At last, the best option seems to be to use <camunda:field><camunda:expression>CONTENT ${with some expression}</camunda:expression></camunda:field>
.
Anyway, I wonder if it would be a good idea to make camunda:field
and camunda:inputParameter
to work in the same way, or are we are missing some point and they must be kept working as they do? In such case, some more detailed documentation might be need about what makes them different and what should each one be used for.