camunda / feel-scala

FEEL parser and interpreter written in Scala
https://camunda.github.io/feel-scala/
Apache License 2.0
123 stars 50 forks source link

Defining and invoking a user defined function in a process context does not work #874

Closed jphillips-bp3 closed 2 months ago

jphillips-bp3 commented 3 months ago

Describe the bug The documentation link below implies that user defined functions can be defined and executed in a process context, but this does not work.

https://docs.camunda.io/docs/components/modeler/feel/language-guide/feel-functions/#user-defined

I can define and execute functions inside a DMN literal decision, but not within a process context.

To Reproduce I created a simple BPMN to try this out. Here is how I can reproduce the issue:

  1. In my start event I defined the following variable with the function:

image

  1. I then called the function from a Script Task:

image

  1. When invoked, the scriptResult variable was null:

image

Expected behavior Given the documentation, I would expect the function to be called and in this example, scriptResult to have the value of 3.

Environment Tested on SaaS:

image

saig0 commented 2 months ago

@jphillips-bp3 thank you for reporting. :+1:

I'm sorry for this confusion but Camunda doesn't support this feature. You can define a function and use it inside the same expression (e.g. in a script task expression or a variable mapping). See the example here. But, it is not possible to serialize/store the function, for example, in a process variable.

However, I see the value in providing common functions for BPMN. Since this is more related to Camunda itself, please open a feature request here as "Zeebe Feature request" and describe your use case in detail. :rocket:

jphillips-bp3 commented 2 months ago

Feature request created here: https://github.com/camunda/camunda/issues/20141