User-defined functions in DMN literal expression

Hi everyone.
I’m probably missing something and I hope you can set me right. This link
implies you can define your own function and call it. However when I try to do this inside of a literal expression it does not work. What am I missing please?
thanks in advance.

Hi @Fraser_Hamilton,

good catch :+1:

It is possible to define a function in a literal expression. But currently, it is not possible to invoke this function in another decision :sweat_smile:

This use case is not supported yet. According to the specification, the function should be defined in a BKM instead.

However, there is a different way to implement and expose custom functions to FEEL expressions: FEEL Engine Custom Functions |

Does this help you?

Best regards,

Hi Philipp, thanks for the reply.
I’m actually talking about invoking a function within the same decision. For example this:
results in:
Caused by: org.camunda.bpm.dmn.feel.impl.FeelException: FEEL/SCALA-01008 Error while evaluating expression: failed to parse expression ‘{
2021-02-20T08:24:32.327171867Z: [ERROR] add : function(x,y) x + y
2021-02-20T08:24:32.327178768Z: [ERROR] }
2021-02-20T08:24:32.327185568Z: [ERROR] add(4, 5)’: [4.1] failure: end of input expected
2021-02-20T08:24:32.327192468Z: [ERROR]
2021-02-20T08:24:32.327199268Z: [ERROR] add(4, 5)
2021-02-20T08:24:32.327206068Z: [ERROR] ^

Okay. This is possible. See here:

Keep in mind that a decision literal expression is just a single expression. So, everything must be computed in this single expression - i.e. no newline. One way is to use bundle the expressions in a context.

Does this help you?

hi, thanks that is a big help. I’ll modify the example provided. Cheers.