Is your feature request related to a problem? Please describe.
If a process has optional variables then the FEEL expressions (e.g. variable mappings) need to deal with optional/nullable variables/values. Otherwise, the expression may fail.
Currently, the best option is to use an if-then-else block with a null-check.
if x != null then x else "default_value"
// or
if is defined(x) then x else "default_value"
But it is very cumbersome.
This issue is also relevant to the integration with forms. In a form, a field may be optional or shown conditionally. The process must deal with these optional form values.
Describe the solution you'd like
There is an easy way to deal with optional/nullable values. For example, by adding a new built-in function:
// signature
get or default(value: Any, default: Any)
// usage
get or default("this", "default") // -> "this"
get or default(null, "default") // -> "default"
Alternative function names: get or else()
Alternative solutions
Instead of adding a built-in function, it would be handy to include this optional/nullable handling natively in expressions.
We have examples in other programming languages. For example:
Is your feature request related to a problem? Please describe. If a process has optional variables then the FEEL expressions (e.g. variable mappings) need to deal with optional/nullable variables/values. Otherwise, the expression may fail.
Currently, the best option is to use an
if-then-else
block with a null-check.But it is very cumbersome.
This issue is also relevant to the integration with forms. In a form, a field may be optional or shown conditionally. The process must deal with these optional form values.
Describe the solution you'd like There is an easy way to deal with optional/nullable values. For example, by adding a new built-in function:
Alternative function names:
get or else()
Alternative solutions
Instead of adding a built-in function, it would be handy to include this optional/nullable handling natively in expressions.
We have examples in other programming languages. For example:
Kotlin:
JavaScript:
Related issues