diff --git a/modules/flowable-cmmn-converter/src/test/java/org/flowable/test/cmmn/converter/ScriptServiceTaskCmmnXmlConverterTest.java b/modules/flowable-cmmn-converter/src/test/java/org/flowable/test/cmmn/converter/ScriptServiceTaskCmmnXmlConverterTest.java
index a9da14dca6a..e999c9fef73 100644
--- a/modules/flowable-cmmn-converter/src/test/java/org/flowable/test/cmmn/converter/ScriptServiceTaskCmmnXmlConverterTest.java
+++ b/modules/flowable-cmmn-converter/src/test/java/org/flowable/test/cmmn/converter/ScriptServiceTaskCmmnXmlConverterTest.java
@@ -84,4 +84,34 @@ public void validateModel(CmmnModel cmmnModel) {
});
}
+
+ @CmmnXmlConverterTest("org/flowable/test/cmmn/converter/script-task-expression-field.cmmn")
+ public void scriptTaskWithExpressionField(CmmnModel cmmnModel) {
+ assertThat(cmmnModel).isNotNull();
+
+ PlanItem planItemTaskA = cmmnModel.findPlanItem("planItemTaskA");
+ assertThat(planItemTaskA.getEntryCriteria()).isEmpty();
+
+ PlanItemDefinition planItemDefinition = planItemTaskA.getPlanItemDefinition();
+ assertThat(planItemDefinition)
+ .isInstanceOfSatisfying(ScriptServiceTask.class, scriptTask -> {
+ assertThat(scriptTask.getType()).isEqualTo(ScriptServiceTask.SCRIPT_TASK);
+ assertThat(scriptTask.getScriptFormat()).isEqualTo("javascript");
+ assertThat(scriptTask.getScript()).isEqualTo("var a = '${testA}';");
+ assertThat(scriptTask.getResultVariableName()).isEqualTo("scriptResult");
+ assertThat(scriptTask.isAutoStoreVariables()).isFalse();
+ assertThat(scriptTask.isBlocking()).isTrue();
+ assertThat(scriptTask.isAsync()).isFalse();
+ });
+
+ PlanItem planItemTaskB = cmmnModel.findPlanItem("planItemTaskB");
+ planItemDefinition = planItemTaskB.getPlanItemDefinition();
+ assertThat(planItemDefinition)
+ .isInstanceOfSatisfying(ScriptServiceTask.class, scriptServiceTask -> {
+ assertThat(scriptServiceTask.getScriptFormat()).isEqualTo("groovy");
+ assertThat(scriptServiceTask.getScript()).isEqualTo("var b = '${testB}';");
+ assertThat(scriptServiceTask.isAutoStoreVariables()).isTrue();
+ });
+ }
+
}
diff --git a/modules/flowable-cmmn-converter/src/test/resources/org/flowable/test/cmmn/converter/script-task-expression-field.cmmn b/modules/flowable-cmmn-converter/src/test/resources/org/flowable/test/cmmn/converter/script-task-expression-field.cmmn
new file mode 100644
index 00000000000..f5609cc3580
--- /dev/null
+++ b/modules/flowable-cmmn-converter/src/test/resources/org/flowable/test/cmmn/converter/script-task-expression-field.cmmn
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/ScriptServiceTask.java b/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/ScriptServiceTask.java
index 36da3d73ae3..7d06dbcdcdf 100644
--- a/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/ScriptServiceTask.java
+++ b/modules/flowable-cmmn-model/src/main/java/org/flowable/cmmn/model/ScriptServiceTask.java
@@ -12,9 +12,7 @@
*/
package org.flowable.cmmn.model;
-import java.util.Optional;
-
-import org.flowable.common.engine.api.FlowableException;
+import org.apache.commons.lang3.StringUtils;
/**
* @author Dennis
@@ -38,11 +36,16 @@ public void setScriptFormat(String scriptFormat) {
}
public String getScript() {
- Optional script = fieldExtensions.stream()
- .filter(e -> "script".equalsIgnoreCase(e.getFieldName()))
- .findFirst()
- .map(FieldExtension::getStringValue);
- return script.orElseThrow(() -> new FlowableException("Missing script"));
+ for (FieldExtension fieldExtension : fieldExtensions) {
+ if ("script".equalsIgnoreCase(fieldExtension.getFieldName())) {
+ String script = fieldExtension.getStringValue();
+ if (StringUtils.isNotEmpty(script)) {
+ return script;
+ }
+ return fieldExtension.getExpression();
+ }
+ }
+ return null;
}
public boolean isAutoStoreVariables() {