I have a flow which calls two sub-flows using flow-refs and a choice conditional flow router.
The first condition in the when section is #[payload.num > 1000]
. When True
this calls sub-flow-A.
when false
, the NEXT when condition to check is #[(payload.num < 1000) and (payload.num > 0)]
. When True
, this calls sub-flow-B, else default.
Is there a way (any operator) to replace the usage #[(payload.num < 1000) and (payload.num > 0)]
to something clean, short and simple ?
There's no built-in operator for that, your best option is to create a dw module in your classpath with that funtion. It's just a dwl file with that function and others if you want and no body.
// src/main/resources/MyModule.dwl
%dw 2.0
fun isBetween(numToCheck: Number, low: Number, high: Number) = do {
(numToCheck > low) and (numToCheck < high)
}
and then you can just call it like:
#[MyModule::isBetween(payload.num, 0, 1000)]