Feel input variable not found

Hi everyrone,
I’m facing an error running this very simple decision table with only a comparison beetwen two input dates, that are evaluated using feel:

Here’s the command for evaluation:
dmnEngine.evaluateDecision(dmnDecision, Variables.putValue(“event”, Spin.JSON("{“processingDate”: “2021-04-19T18:00:00.151”, “remittanceDate”: “2021-04-19T18:00:00.151”}")));

The error is that the engine failed to evaluate expression ‘> processingDate’ because no variable found for name ‘processingDate’.

It looks like the variable ‘processingDate’ was not stored in context even if ‘Input variable’ is filled.

Here’s the full stacktrace:
org.camunda.bpm.dmn.feel.impl.FeelException: FEEL/SCALA-01008 Error while evaluating expression: failed to evaluate expression ‘> processingDate’: ValError(no variable found for name ‘processingDate’) is not comparable
at org.camunda.bpm.dmn.feel.impl.scala.ScalaFeelLogger.evaluationException(ScalaFeelLogger.java:77)
at org.camunda.bpm.dmn.feel.impl.scala.ScalaFeelEngine.evaluateSimpleUnaryTests(ScalaFeelEngine.java:117)
at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.evaluateFeelSimpleUnaryTests(DecisionTableEvaluationHandler.java:246)
at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.evaluateInputEntry(DecisionTableEvaluationHandler.java:203)
at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.isConditionApplicable(DecisionTableEvaluationHandler.java:145)
at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.evaluateInputForAvailableRules(DecisionTableEvaluationHandler.java:137)
at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.evaluateDecisionTable(DecisionTableEvaluationHandler.java:111)
at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.evaluate(DecisionTableEvaluationHandler.java:81)
at org.camunda.bpm.dmn.engine.impl.DefaultDmnDecisionContext.evaluateDecision(DefaultDmnDecisionContext.java:85)
at org.camunda.bpm.dmn.engine.impl.DefaultDmnEngine.evaluateDecision(DefaultDmnEngine.java:167)
at org.camunda.bpm.dmn.engine.impl.DefaultDmnEngine.evaluateDecision(DefaultDmnEngine.java:158)

Thanks for your help

Hi @Mika,

inputVariable is only recognized in input entry for which expressionLanguage is set to non FEEL value (for example: JUEL)

You can redesign your DRD as follow

Kindly find attached a simplified running example
decision-main.dmn (4.6 KB)
test-main-decision.bpmn (3.5 KB)

1 Like

Thanks Hassang for your quick answer. I can’t use pre evaluation using literal expressions because my real DRD is much bigger in reality and will become unreadable. Do you know why is there a such behavior with FEEL ? By the way I will switch to JUEL

Hi @Mika,

Then, you can redesign your decision table to have a single input variable “event” and use below as input entry condition(s)

date and time(get value(?, "processingDate")) > date and time(get value(?, "remittanceDate"))

date and time(get value(?, "processingDate")) <= date and time(get value(?, "remittanceDate"))

1 Like

Hi @hassang ,
We have considered this alternative but it has the disadvantages of degrading visibility and especially performance with duplicated path evaluations

1 Like

The limitation of FEEL could be avoided correcting org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler:

protected void evaluateDecisionTable(DmnDecisionTableImpl decisionTable, VariableContext variableContext,
		DmnDecisionTableEvaluationEventImpl evaluationResult) {
	int inputSize = decisionTable.getInputs().size();
	List<DmnDecisionTableRuleImpl> matchingRules = new ArrayList<DmnDecisionTableRuleImpl>(
			decisionTable.getRules());
	for (int inputIdx = 0; inputIdx < inputSize; inputIdx++) {
		// evaluate input
		DmnDecisionTableInputImpl input = decisionTable.getInputs().get(inputIdx);
		DmnEvaluatedInput evaluatedInput = evaluateInput(input, variableContext);
		evaluationResult.getInputs().add(evaluatedInput);

		// compose local variable context out of global variable context enhanced with
		// the value of all evaluated inputs
		VariableContext localVariableContext = getLocalVariableContext(input, evaluatedInput.getInputVariable(), evaluationResult.getInputs(), variableContext);

		// filter rules applicable with this input
		matchingRules = evaluateInputForAvailableRules(inputIdx, input, matchingRules, localVariableContext);
	}
	setEvaluationOutput(decisionTable, matchingRules, variableContext, evaluationResult);
}

protected VariableContext getLocalVariableContext(DmnDecisionTableInputImpl input, String inputVariableName, List<DmnEvaluatedInput> evaluatedInputs,
		VariableContext variableContext) {
	if (isNonEmptyExpression(input.getExpression())) {
		VariableMap variables = Variables.createVariables();
		variables.putValue("inputVariableName", inputVariableName);
		for (DmnEvaluatedInput evaluatedInput : evaluatedInputs) {
			variables.putValueTyped(evaluatedInput.getInputVariable(), evaluatedInput.getValue());
		}
		return CompositeVariableContext.compose(
				variables.asVariableContext(),
				variableContext);
	} else {
		return variableContext;
	}
}

Is there a way to integrate this contribution ?

Hi @Mika,

the ways to contribute are explained here: camunda-bpm-platform/CONTRIBUTING.md at master · camunda/camunda-bpm-platform · GitHub and here: camunda-bpm-platform/CONTRIBUTING.md at master · camunda/camunda-bpm-platform · GitHub

Hope this helps, Ingo