Retrieving decision instance id

Hello,

we are evaluating a decision table outside of a process model or case model but directly in java.

Therefore, we use the following code snippet:

DmnDecisionTableResult decisionResult = processEngine.getDecisionService()
.evaluateDecisionTableByKey(id, Variables.createVariables());
DmnDecisionRuleResult dmnResult = decisionResult.getSingleResult();

Now we want to keep track of all evaluations. In the Camunda Cockpit, there is an unique instance id for each of the evaluations. Is it possible to retrieve the decision instance id via the API directly after the evaluation?

With the following statement, we can not be sure what really is the last evaluation we performed when multiple processes are running.

processEngine.getHistoryService().createHistoricDecisionInstanceQuery().list();

Thank you in advance!
Kind regards

1 Like

Hi @mhoc,

currently, there is no way to retrieve the decision instance id after the evaluation. This id is only used for the history.

Best regards,
Philipp

Hello @Philipp_Ossler,

ok, thank you for your answer!

Its quite an old thread, but I just stumbled upon the same requirement, and while this is not supported out-of-the-box I hacked a quick plugin to capture that Id. I wanted to share that here for reference.

The code necessary was basically:

Hope that helps, Bernd.

1 Like

Hi Bernd! Great that you suggested a solution. However, this only work if you are coding in Java. We are using the engine strictly on a REST basis (which you have said is no problem ;-). Do you have a small snippet or suggestion on how we can get the DecisionID when using REST? Best regards, Finnur

Hey Finnur!

Can you describe your requirement in more detail? Personally I think it will be hard in a REST only mode unless the ID is added there somewhere. But to propose such a feature request it would be important to understand the WHY. Thanks!

Best, Bernd.

1 Like

Hi Bernd.

I can’t see if Finnur ever provided requirements for this feature, but I find myself wondering about the same thing :slight_smile:

If you evaluate a decision directly using the REST API (no BPMN involved, just a decision table) the result of the decision evaluation only contains the output (result) of the decision evaluation, not the decisionInstanceId. This seems a bit odd, because if you would ever like to get more information about that specific decision evaluation (using GET /history/decision-instance/{id} ) you will need that decisionInstanceId to make the call.

So from my perspective adding the decisionInstanceId to the output json of the decision evaluations (e.g. POST /decision-definition/key/{key}/evaluate) would make this more intuitive.

Best regards
Claus Poulsen

3 Likes

Hi,

I have exactly the same question. Calling a DMN direct via REST will get a nice result. But I need the corresponding decisionInstanceId.

Any other thoughts how to solve this?

Regards,

Lennart

1 Like

I´m also very interested in this feature. :muscle:
I´m building an external decision service and i need decisionInstanceId to keep traceability.

The post method could be

‘/engine-rest/decision-definition/key/{key}/evaluate-with-id

And the result:

{
"decisionInstanceId": "00000-00000-00000-00000",
"result":[
    {
        "active": {
            "type": "Boolean",
            "value": true,
            "valueInfo": {}
        }
    }
]
}

Thanks. Camunda :rocket:

1 Like

is it supported out of the box in Camunda 8 now ? basically in Camunda 8 -

  1. Is there a way to search for decision instances using data which is not used for decision evaluation - i.e using any data which is not used as an input of my DMN decision table ?
  2. and with that how can we use any business data which is used in decision evaluation to find the decision instances ?
  3. how to find the decision instance id/key of a decision evaluated from a grpc client say java or c# ?

thanks in advance