Unable to use Process variable in Script take In script

In my bpmn process Camunda 8,

The process variable firstName has some value from feel expression. I would like to use this firstName variable into my script task as script variable

FEEL EXPRESSION RESULT BLOCK FROM PREVIOUS PROCESS
<zeebe:header key=“resultExpression” value=“={firstName : response.body.fseShortInfo.firstName, lastName : response.body.fseShortInfo.lastName, }” />
<zeebe:header key=“retryBackoff” value=“PT0S” />

SCRIPT BLOCK
<bpmn:scriptTask id=“Activity_0pwavfl” name=“scriptJobWorker”>

<zeebe:taskDefinition type=“script” />
zeebe:taskHeaders
<zeebe:header key=“language” value=“groovy” />
<zeebe:header key=“script” value=“def templateText = "Hello, @@name@@! I am @@age@@ years old."; def variableMap = [ age: 30, name: execution.getVariable("firstName") ]; def replaceVariables(template, variables) { variables.each { key, value -> template = template.replaceAll("@@$key@@", value.toString()); }; return template; }; def replacedText = replaceVariables(templateText, variableMap); return replacedText;” />
</zeebe:taskHeaders>
zeebe:ioMapping
<zeebe:input source=“=activityID” target=“x” />
<zeebe:output source=“=result” target=“resultOfScriptTask” />
<zeebe:output source=“=replacedText” target=“replacedText” />
</zeebe:ioMapping>
</bpmn:extensionElements>
</bpmn:scriptTask>

this execution.getVariable(“firstName”); is not executable.

Error:
2024-03-11T14:36:35.125+05:30 WARN 15564 — [ool-68-thread-1] io.camunda.zeebe.client.job.worker : Worker scriptJobWorker failed to handle job with key 2251799815397442 of type script, sending fail command to broker

groovy.lang.MissingPropertyException: No such property: execution for class: Script1
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53) ~[groovy-2.4.6.jar:2.4.6]
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:52) ~[groovy-2.4.6.jar:2.4.6]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307) ~[groovy-2.4.6.jar:2.4.6]
at Script1.run(Script1.groovy:1) ~[na:na]
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:585) ~[groovy-2.4.6.jar:2.4.6]
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:623) ~[groovy-2.4.6.jar:2.4.6]
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:594) ~[groovy-2.4.6.jar:2.4.6]
at com.zeebe.camunda.ProductOrder.evaluateGroovyScript(ProductOrder.java:148) ~[classes/:na]
at com.zeebe.camunda.ProductOrder.script(ProductOrder.java:136) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
at io.camunda.zeebe.spring.client.bean.MethodInfo.invoke(MethodInfo.java:51) ~[spring-client-zeebe-8.3.1.jar:8.3.1]
at io.camunda.zeebe.spring.client.jobhandling.JobHandlerInvokingSpringBeans.handle(JobHandlerInvokingSpringBeans.java:54) ~[spring-client-zeebe-8.3.1.jar:8.3.1]
at io.camunda.zeebe.client.impl.worker.JobRunnableFactoryImpl.executeJob(JobRunnableFactoryImpl.java:45) ~[zeebe-client-java-8.3.0.jar:8.3.0]
at io.camunda.zeebe.client.impl.worker.JobRunnableFactoryImpl.lambda$create$0(JobRunnableFactoryImpl.java:40) ~[zeebe-client-java-8.3.0.jar:8.3.0]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[na:na]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]

What is the issue here ?

Hi @Shivam_Agrawal, welcome to the forums! Camunda 8’s script task is different than the C7 implementation. With C8, you need to implement a job worker that executes the script, as the engine no longer executes scripts directly for security reasons. You learn more here:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.