FEEL custom function with space in method name

How should one implement a custom function that contains a space character in the method name? Examples of built in functions that have this are string join(list: list<string>): string and day of week(date: date): string. See the following code block for a simplified example of what I’m trying to achieve.

class CustomScalaFunctionProvider extends CustomFunctionProvider {

  def getFunction(name: String): Option[ValFunction] = functions.get(name)

  def functionNames: Iterable[String] = functions.keys

  val functions: Map[String, ValFunction] = Map(
    "do incr" -> ValFunction(
      params = List("x"),
      invoke = { case List(ValNumber(x)) => ValNumber(x + 1) }
    )
  )

}

Hi @Luukth,

welcome to the community. :wave:

Good question.

Does it work with the provided code?
What Camunda version do you use?

Hi @Philipp_Ossler and thanks for the welcome!

Sadly the provided code does not work.

We are using Camunda Engine 7.11.0 in combination with the FEEL Scala engine version 1.9.0 feel-scala/feel-engine-factory at 1.9.0 · camunda/feel-scala · GitHub

The following error pops up when running the do incr function.

failed to evaluate expression 'do incr(1)': no variable found for name 'do'

We found out that putting backticks around the function works but we would like to avoid that.

`do incr(1)` // result is 2

I’ll try to reproduce this issue on a more recent version while awaiting a response.

I was able to reproduce the above described issue in feel-engine versions 1.9.0 until 1.13.0 On version 1.14.0 it is fixed and I’m able to use spaces in the function name.

This probably means we can close this topic with the solution to update the feel-engine to version 1.14.0 or higher.

1 Like

Great new. :tada:

You should update to the least recent Camunda version 7.20. :rocket:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.