DMN Test for Empty Variable


#1

I have a dmn file (attached) in which I want to test whether one of the variables is empty. The evaluation is failing with ‘Exception while evaluating decision with key ‘null’’. The input variable is a type date and the input value is null. Is there another approach?

I am calling this Decision within a groovy script below, in which the variable followUpDate is null.

def setPriority(taskName) {
    def dmnEngine = task.execution.getProcessEngineServices().getDecisionService()
    def rush = task.execution.getVariable("rush")
    def followUpDate  = task.execution.getVariable("followUpDate")
    def clientDueDate = task.execution.getVariable("clientDueDate")
    println("Rush: " + rush)
    println("FollowUp Date: " + followUpDate)
    println("ClientDue Date: " + clientDueDate)
    def dmnKey = "TaskPriority_1"
    def variables = Variables
            .putValue("rush", rush)
            .putValue("task", taskName)
            .putValue("followUpDate", followUpDate )
            .putValue("clientDueDate", clientDueDate)
    result = dmnEngine.evaluateDecisionTableByKey(dmnKey, variables)
    def priorityLevel = result.getSingleResult().get("priorityLevel")
    def priorityDate = result.getSingleResult().get("priorityDate")
    task.setVariableLocal("priorityLevel",priorityLevel)
    task.setVariableLocal("priorityDate",priorityDate)

TaskPriority.dmn (6.6 KB)


#2

I was able to resolve my issue myself. I moved the empty test out of the rule and into the input expression. TaskPriority.dmn (7.5 KB)