{"record":{"id":"1d1f63d8288ff530","repo":"flowable/flowable-engine","slug":"the-field-script-should-be-set-on-the-tasklisten","errorCode":null,"errorMessage":"The field 'script' should be set on the TaskListener","messagePattern":"The field 'script' should be set on the TaskListener","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/listener/ScriptTypeTaskListener.java","lineNumber":81,"sourceCode":"\n        ScriptEngineRequest.Builder request = ScriptEngineRequest.builder()\n                .script(script)\n                .language(language)\n                .scopeContainer(delegateTask)\n                .traceEnhancer(trace -> trace.addTraceTag(\"type\", \"taskListener\"));\n        Object result = scriptingEngines.evaluate(request.build()).getResult();\n\n        if (resultVariable != null) {\n            String resultVariable = Objects.toString(this.resultVariable.getValue(delegateTask), null);\n            if (resultVariable != null) {\n                delegateTask.setVariable(resultVariable, result);\n            }\n        }\n    }\n\n    protected void validateParameters() {\n        if (script == null) {\n            throw new IllegalArgumentException(\"The field 'script' should be set on the TaskListener\");\n        }\n\n        if (language == null) {\n            throw new IllegalArgumentException(\"The field 'language' should be set on the TaskListener\");\n        }\n    }\n\n    public void setScript(Expression script) {\n        this.script = script;\n    }\n\n    public void setLanguage(Expression language) {\n        this.language = language;\n    }\n\n    public void setResultVariable(Expression resultVariable) {\n        this.resultVariable = resultVariable;\n    }","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/listener/ScriptTypeTaskListener.java#L63-L99","documentation":"ScriptTypeTaskListener executes a script when a CMMN task/listener event fires. Before evaluating, validateParameters() (called from notify()) checks that both the 'script' and 'language' fields were configured; this error means the 'script' Expression field was never set on the listener definition.","triggerScenarios":"A CMMN model declares a ScriptTypeTaskListener whose <flowable:field name=\"script\"> element (or programmatic setScript) is missing, so script == null when notify() runs during plan-item/task event handling.","commonSituations":"Hand-edited or generated CMMN XML where the script field was omitted or misspelled (field name must be exactly 'script'); dynamically creating listener via code and forgetting setScript; model deployed from a template with placeholder script values left null.","solutions":["Add a field named 'script' with the script text/expression to the listener definition in the CMMN XML: <flowable:field name=\"script\"><flowable:string><![CDATA[...]]></flowable:string></flowable:field>","If building the listener programmatically, call setScript(expression) before deploying/executing","Redeploy the corrected CMMN model and re-run the case"],"exampleFix":"// before\n<flowable:taskListener event=\"complete\" class=\"org.flowable.cmmn.engine.impl.listener.ScriptTypeTaskListener\">\n  <flowable:field name=\"language\" stringValue=\"javascript\"/>\n</flowable:taskListener>\n// after\n<flowable:taskListener event=\"complete\" class=\"org.flowable.cmmn.engine.impl.listener.ScriptTypeTaskListener\">\n  <flowable:field name=\"script\"><flowable:string><![CDATA[println('done')]]></flowable:string></flowable:field>\n  <flowable:field name=\"language\" stringValue=\"javascript\"/>\n</flowable:taskListener>","handlingStrategy":"validation","validationCode":"const fields = listenerDef.fields || {};\nif (!fields.script || !fields.script.stringValue) throw new Error('ScriptTypeTaskListener: missing script field');","typeGuard":"function hasScript(l) { return l != null && l.script != null && l.script.expressionText != null; }","tryCatchPattern":"try { deployModel(model); } catch (e) { if (String(e.message).includes(\"field 'script' should be set\")) { fixListenerDefinition(model); } else { throw e; } }","preventionTips":["Always include both 'script' and 'language' fields in ScriptTypeTaskListener definitions","Validate CMMN XML against the Flowable XSD before deployment","Add a deploy-time smoke test that exercises each listener"],"tags":["cmmn","task-listener","scripting","configuration"],"backgroundTag":"missing-required-config-field","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}