Script task Issue with Camunda-8

Hi,
I am using camunda-8 script task to execute groovy script.
I have configured below script -

<bpmn:scriptTask id=“Activity_12hkahq” name=“test script”>
bpmn:extensionElements
zeebe:taskHeaders
<zeebe:header key=“language” value=“groovy” />
<zeebe:header key=“script” value=“execution.setVariable(“test”,“AB0001”); execution.setVariable(“testName”,“Name”);” />
<zeebe:header />
</zeebe:taskHeaders>
<zeebe:taskDefinition type=“script” />
</bpmn:extensionElements>
bpmn:incomingFlow_02kxtap</bpmn:incoming>
bpmn:outgoingFlow_0d14eyx</bpmn:outgoing>
</bpmn:scriptTask>

getting below issue in the worker execution -

**java.lang.RuntimeException: Failed to evaluate script ’ execution.setVariable(“test”,“AB0001”); **
execution.setVariable(“testName”,“Name”) ’ (groovy)

same script was working with Camunda-7, Can you guys please help me how to achive same output in camunda-8.

@Niall Can someone please helm me with this issue ?

Hi @yogeshwer,

There is a difference in implementing script Task in Camunda 7 and Camunda 8: Camunda 8 does not execute your scripts. Instead, script tasks in Camunda 8 are configured in the same way as service tasks in Camunda 8. This means, you have to provide a worker to perform your script tasks. You can write a worker that is capable of evaluating scripts. You can read more about script tasks in Camunda 8 in our documentation.
However, using FEEL (instead of Groovy) and Business Rule Tasks (instead of script tasks) allows you to write tasks that are evaluated by Camunda 8 directly. This may be a viable solution for your use case.

3 Likes

Hi @StephanHaarmann ,

I am using below script worker -

Can’t I pass the script to execute using script worker ?

You can pass a script, but there is no execution object.

How it will be mapped back to the process ?
If you can give some small example to read the process variable and set the response variable, it will be great help ?
I am blocked because of this issue.

Thanks.

Hi,
The readme of the zeebe-script-worker states:

the result of the evaluation is passed as result variable

The repository also contains a simple example.

In the following, another an example that works for me:
scriptTaskExample.bpmn (3.6 KB)
The example has a script task that calculates x+2. Currently, it uses an input mapping that sets x to 4. The result is then mapped to the variable resultOfScriptTask which can be viewed in the user task. I used the Standalone Jar of the Zeebe Script Worker linked above.

2 Likes