Writing custom filter script on Camunda 7 DMN

115 views Asked by At

I am creating a DMN file where based on certain ingredient percentages, we need some comment on beverages. I need to use a rest call to request and evaluate the drinks. I will pass all the ingredients in JSON post request.

How would I achieve this? Note that, we also need some null checks, incase there is no ingredient listed here.

In short the pseudocode looks like following:

if sugar is present in Cola:
 return ingredient.sugar
else
 return 0

How would I write custom code/function on cell block?

I am sharing the screenshot of the current state (without null check) DMN. Got error: { "type": "RestException", "message": "Cannot evaluate decision Food:1:1c8bc453-4d53-11ee-b0ae-12d907201e30: Exception while evaluating decision with key 'null'" } Rest call

1

There are 1 answers

0
rob2universe On

variables is a list. Please take a look at the example request here: https://docs.camunda.org/rest/camunda-bpm-platform/7.19/#tag/Decision-Definition/operation/evaluateDecisionByKey

Also make sure the keys in the DMN column headers are set and match your variable ids.

If this does not help, please share the DMN (XML).