DMN - eval script functions in row

Hi,

Let’s say I have a workflow with 2 tasks.
The first task is a manual task where I map an output variable named abc which is a Groovy script function e.g.: Integer score() { return 10; }
The second task is a Business rule task (DMN) and I would like to use the previously mapped abc Groovy script in an inserted row.
Can I refer to abc.score() function in a DMN’s row output somehow? If yes, how?

So, basically I would like to call several Groovy script in DMN output cell and summarize them but I must use functions and cannot write simple scripts. Because I have approx. 3000 functions. I do not want Camunda to totally evaluate all output script when the token reach the manual task but eval as a function reference (like a script repository). And when the token reaches the appropriate row in the DMN, then should evaluate only e.g. 30 functions.

Thank you for your help in advance.

Hi @Romeo_Nagy,

I’m not sure if DMN is the best solution for your use case. However, you can evaluate an expression in an output entry which uses an existing bean. In JUEL (the default expression language) you can use ${abc.score()} as output entry.
Note that you can also change the expression language.

Does this work for you?

Best regards,
Philipp

Hi @Philipp_Ossler,

Thank you for your reply, but unfortunately when I try to simulate the workflow as you wrote, it throws an exception:
org.camunda.bpm.dmn.engine.impl.DmnEvaluationException: DMN-01002 Unable to evaluate expression for language ‘juel’: ‘${abc.score()}’

Best regards,
Romeo

Hi Romeo,

can you please provide a simple failing test?
This would help to analyse your issue.

Best regards,
Philipp

Hi,

I have my own test environment (so I will not attach that) which is actually just run the process till end and checks the history variables. However I attached the BPMN and the DMN files. Hope it will be enough. Maybe I just miswritten something.

mockActive.bpmn (4.2 KB)

Best regards,
Romeo

Sorry but I am so newbie that I cannot attach 2 files in one reply.
Here is the DMN:
proba.dmn (876 Bytes)

Thank you.

Hi Romeo,

it seems that the groovy function can’t be stored in a process variable. Since I don’t know much about Groovy, I can’t show you how to do this or say if it’s even possible.
Additionally, I’m not sure if it’s the right way to declare a function in a process like this. Maybe you can just invoke a predefined function somehow.

Best regards,
Philipp

Yes, it seems. Anyway, thank you Philipp.