How to check if the result variable in null or not in flowable

Hi, I am trying to execute an process. I want to check if the result value is null take task1 if not null want to end the process. Please advice.

Flowable process xml



targetRef=“paramValGateWayError”>

</sequenceFlow>
<sequenceFlow id="flow7" sourceRef="paramValGateWayError" targetRef="servicetask2">
        <conditionExpression xsi:type="tFormalExpression">${validationError != null}</conditionExpression> 
</sequenceFlow>
<sequenceFlow id="flow10" sourceRef="paramValGateWayError" targetRef="endevent3">
            <conditionExpression xsi:type="tFormalExpression">${validationError == null}</conditionExpression> 
</sequenceFlow>
   <endEvent id="endevent3" name="End"></endEvent>

code snippet written in kotlin

fun checkForValidOperation(map: Map<String, Any>): CustomGraphQLException? {

    if (!map.containsKey("checkParam") || !map.containsKey("validationKey")) {
        throw Exception("Arguement are not properly configured")
    }

    if (!(map.get("checkParam") is String) || !(map.get("validationKey") is String)) {
        throw Exception("Invalid parameter")
    }

    val chkParam = (map.get("checkParam") as String).split(",")
    val checkKey = (map.get("validationKey") as String).split(",")

    val lst = mutableListOf<GraphQLErrorAttribute>()

    checkKey.forEachIndexed() { index, element ->
        when (element) {
            "email" -> if (!isValidEmail((map.get(chkParam[index])) as String)) {
                lst.add(ErrorAttribute(1001, "Invalid email format", chkParam[index]))
            }
            "number" -> if (!isValidNumber((map.get(chkParam[index])) as String)) {
                println("is Valid Numer check is addressed")
                lst.add(ErrorAttribute(1002, "Invalid number format", chkParam[index]))
            }
            else -> throw Exception("Parameter for check in not available") // unreachable for safety
        }
    }

    if (lst.isNotEmpty()) {
        println("throwing error")
        return CustomException("Parameter Validation Exception", lst)
    }
    return null
}

one more doubt do I need to set the variable in DelegateExecution or shall as return such that flowable will add to the result variable.

Is there any option to check if the result is instance of ( ie I need to check if the result value is instance of Error Object or String Object ). Please advise on this

Please provide me a sample snippet on this case.

Thanks,

Hey @kcraghu,

I would suggest you to look at the available Expression Functions. You can use variables::exists('validationError'), this would return true if the process has a non null variable with the name validationError.

This is up to you. If you use an expression then you would need to return and and set the result variable name in the service task. If you are using a delegate expression or class then you would need to implement JavaDelegate and set the variable in the DelegateExecution.

Sorry, but I don’t quite understand what are you looking for here.

Cheers,
Filip

Thank you for the response and it is more helpful for us.

In my case, my service task ( java ) may return an object which may be ErrorObject or ResultObject. We need take the gateway sequence flow based on the java instance type. Is there any option or function available ?

Regards,
Raja