How to return applied rule(s)

Hello everyone,

I’m currently trying to not only get the output result from my DmnDecisionTableResult but get the DMN engine to return the rule this output result belongs to.
My guess is it is possible to return it, I am just not looking at the right place.

The DMN Online Simulator automatically highlights the correct rule which was found and when I fooled around with https://dmn.lab.camunda.com/ I can see a rule response, which is exactly what I am looking for.

{
  "outputs": {
    "dish": {
      "type": "string",
      "values": [
        "Light Salad and a nice Steak"
      ]
    }
  },
  "rules": [
    {
      "ruleId": "row-950612891-6",
      "outputs": {
        "dish": {
          "type": "string",
          "value": "Light Salad and a nice Steak"
        }
      }
    }
  ]
}

How can I get this rules returned by the JAVA API?

Thanks in advance!

Hi @divY42,

you can get the information from the history. When a decision is evaluated within Camunda BPM then the history is written. It contains which rules are matched and more.

Best regards,
Philipp

HI – Can you tell me exactly which object provides the rule history ?

Never mind. I figured it out.
Had to add a PostDecisionTableEvaluationListeners to the config to get that information.

@johnasvini, PostDecisionTableEvaluationListeners is this your custom implementation class?

I solved it by implementing the DmnDecisionTableEvaluationListener and registered to the dmn configuration and built along with process engine.

public class PostDecisionTableEvaluationListener implements DmnDecisionTableEvaluationListener {

  @Override
  public void notify(DmnDecisionTableEvaluationEvent decisionTableEvaluationEvent) {
         
    //implementation logic to process the decision inputs, output or matched rule, etc.

  }

}

Now the problem is, I want to execute this evaluation listener only for certain decision tables. How can we achieve that? Currently I configured as part of the DMN engine configuration, so it applied for all the decision tables.