Using DMN-table in CMMN Case for a Sentry

Hello,

in this DMN- tutorial you give an example how to use a decision table in the following CMMN-Case for a Sentry:

How can i reference the dmn in the if part of an entry criterion? In the Sentry-Documentation i cant find anything like that.

If it is not possible, how can i integrate and use it for evaluating the Sentry as you did?

Thanks a lot for your help! =)

1 Like

Hi @Andy,

Yes it is possible to use a decision table for the if part of a sentry. But there is not attribute (or something like that) to reference the dmn in the if part.

You can use an expression which calls a method of a bean. There you could evaluate a decision table.

This could for example look like that:

  <sentry id="Sentry_1">
    <ifPart>
      <condition>${myBean.evaluateDecision(caseExecution)}</condition>
    </ifPart>
  </sentry>

The implementation MyBean#evaluateDecision() could be as followed:

public class MyBean {

  public boolean evaluateDecision(DelegateCaseExecution caseExecution) {
    ProcessEngineServices services = caseExecution.getProcessEngineServices();
    DecisionService decisionService = services.getDecisionService();
    DmnDecisionTableResult decisionResult = decisionService.evaluateDecisionTableById("..").evaluate();
    
    // do something with the result
    boolean result = ...;
    
    return result;
  }

}

It is important that the invoked method must return a boolean value.

Does it help you?

Cheers,
Roman

Thanks Roman for your detailed answer. It helped a lot. I will try it.

For my understanding:
<condition>${myBean.evaluateDecision(caseExecution)}</condition>
Is this a Camunda-Feature, that allows to use such expressions like “${…}” or is it part of the CMMN Standard?

Does this approach work with any scope of a bean? (@SessionScoped, @RequestScoped, etc.)

Hi @Andy,

No it is not part of the CMMN Standard. The CMMN standard only specify that the condition of the if part must be an expression. And Camunda BPM uses therefore JUEL (Java Unified Expression Language) (see 1).

To be honest, I am not sure. But I would say yes. Just try it out :wink:

Cheers,
Roman

Hi folks,

this sound very interesting, as it maked sentries much more powerful, because I can execute DMN or any other custom logic.

One further question: What about test support? When testing BPMN processes (using camunda-bpm-mockito) I can easily register delegate (or listener or…) mocks and unit test my process without writing a single line of java delegate code.

What about those custom beans? They are not JavaDelegate and I cannot use a DelegateExpression on a sentry. Is there any “native” test support or do I have to manage that using Spring’s testing capabilities?

Cheers,
Stefan

1 Like

Answering myself:

I can easily register a mock for such a Bean with Mocks.register("id", myMockedBean).

This is really awesome :slight_smile: