task.execution.setVariableLocal

Greetings,
I am trying out a process , where in task listener create , executed a script - task.execution.setVariableLocal(‘recallflag’,‘N’);

This assignment works good in camunda 7.14 and process instance created successfully. But the same is throwing error with version 7.16 - “Cannot read property ‘setVariableLocal’ of undefined”.

Please find attached error and bpmn. Error.txt (3.1 KB)
tryout3.bpmn (7.5 KB)

Thanks

Hey @rathina_karthik ,

I just deployed your model to a fesh Camunda 7.16 Spring Boot instance. And it works fine for me. the local task variable is created with the code from the script.

The error seems to come from graalvm. How do you run your Camunda 7.16 instance? I would assume it is something about the the setup of the instance, but not 100% sure as I can’t reproduce it.

Kind regards
Nele

Hi @Nele
Thank you for your response. I am trying with 7.16 community version - tomcat distribution. Few other members in my team also facing same issue with 7.16 tomcat distribution. Kindly advise.

Thanks
Rathina

Hi @rathina_karthik ,
Heads up or maybe better heads down. With Tomcat I am running into the same issue. I don’t know what is causing this.

A work around would be to use a Script Task before the User task to set the variable locally. A co-worker tested it and got the wanted result. Nevertheless this feels not like a good solution. I would considered it more as a work around, if you need something for now.

I hope we will get some feedback on the topic after the holidays. We keep you posted!
Cheers
Nele

Hello. We are also seeing this error with the Tomcat distribution - 7.16.0.

We have a User Task with a Task Listener defined as follows:
- Event Type: complete
- Listener Type: javascript
- Script Type: inline script
- Script: task.execution.setVariable(“status”, “started”);

We get the following error in the log. Is there any update on resolving this issue?

11-Feb-2022 21:18:25.314 SEVERE [http-nio-8080-exec-20] org.camunda.commons.logging.BaseLogger.logError ENGINE-16004 Exception while closing command context: ENGINE-03051 There was an exception while invoking the TaskListener. Message: 'Unable to evaluate script while executing activity 'e0cb977e_899e_4d80_9a53_69a9dee9aafb_Burn_UserTask_ErrorHandler' in the process definition with id '31cfec40-8abb-11ec-bb98-0242ac170004':org.graalvm.polyglot.PolyglotException: TypeError: Cannot read property 'setVariable' of undefined'

Hi
Why don’t you use task.setVariable(“x”,“y”) ?

1 Like

Thank you. That could work. Of course changing the model implementation doesn’t really help for already deployed and running instances.

You should change your language to Groovy. Then it works

We are getting the same issue. We have process instances running on previous versions of camunda so cannot change the language to groovy otherwise we will have to migrate all processes. org.graalvm.polyglot.PolyglotException: TypeError: Cannot read property ‘setVariable’ of undefined’ only comes when the language used is javascript for scripting. Is there any alternate?

I am trying to do

task.execution.setVariable('starter', task.getAssignee());

but it is throwing error.

Hi

I noticed a blog entry about the change of JavaScript engine for Camunda 7.16. I have not looked closer into this, but maybe there is some help there:

BR
Michael