Array of variable values in Request to match the input values in the row

Hi I am new to Camunda and DMN.
I have a use case below.
Input column in DMN table is activities_to_perform.
Row 1 has values (Activity_1, Activity_2 , Activity_3, Activity_4).
Row 2 has values (Activity_3, Activity_5, Activity_6, Activity_7)

In request body i want to send activities : [Activity_3, Activity_7 ]
In the DMN Engine it has to pass with Row2
Hence the condition should be “For all the values in the request body variable (activities) array” should be subset of the input values array. i.e, inputValues.containAll(requestbody variable array).

[Activity_3, Activity_5, Activity_6, Activity_7].containAll([Activity_3, Activity_7 ])

Somebody please suggest the way to achieve this in Camunda.

Hi @Satya_Kumar,

using Camunda BPM 7.13, you can express this condition as a FEEL expression in the input expression or input entries.

Example FEEL expression:

every activity in ? satiesfies list contains([Activity_3, Activity_5, Activity_6, Activity_7], activity)

? represents the input value of the input expression.

Does this help you?

Best regards,
Philipp

Can you also help me with the request body format as for the same?
like
{
“variables” : {
“activity” : {“value” : [“Activity_3”,“Activity_7”] , “type” : “String”}
}
}

It should work if you set the type to json.

Decision_Packages.dmn (2.9 KB)

Can you help me with that FEEL expression.

I want to send “Lunch”, “Drink” as package.
In the DMN table Row 6 should be passed.

sorry for asking too much.

I am entirely new and evaluating the tool for our use-cases.

I get the following error while executing the rest api.

Caused by: org.camunda.bpm.dmn.feel.impl.juel.FeelSyntaxException: FEEL-01010 Syntax error in expression ‘every package in packages satisfies list contains([“Lunch”, “Dinner”,“Drink”], package)’
at org.camunda.bpm.dmn.feel.impl.juel.FeelEngineLogger.syntaxException(FeelEngineLogger.java:27)
at org.camunda.bpm.dmn.feel.impl.juel.FeelEngineLogger.invalidExpression(FeelEngineLogger.java:113)
at org.camunda.bpm.dmn.feel.impl.juel.FeelEngineImpl.transformSimpleUnaryTests(FeelEngineImpl.java:92)
at org.camunda.bpm.dmn.feel.impl.juel.FeelEngineImpl.evaluateSimpleUnaryTests(FeelEngineImpl.java:53)
at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.evaluateFeelSimpleUnaryTests(DecisionTableEvaluationHandler.java:245)
at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.evaluateInputEntry(DecisionTableEvaluationHandler.java:202)
at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.isConditionApplicable(DecisionTableEvaluationHandler.java:144)
at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.evaluateInputForAvailableRules(DecisionTableEvaluationHandler.java:136)
at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.evaluateDecisionTable(DecisionTableEvaluationHandler.java:110)
at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.evaluate(DecisionTableEvaluationHandler.java:80)
at org.camunda.bpm.dmn.engine.impl.DefaultDmnDecisionContext.evaluateDecision(DefaultDmnDecisionContext.java:84)
at org.camunda.bpm.dmn.engine.impl.DefaultDmnEngine.evaluateDecision(DefaultDmnEngine.java:166)
at org.camunda.bpm.engine.impl.dmn.invocation.DecisionInvocation.invoke(DecisionInvocation.java:56)
at org.camunda.bpm.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:57)
at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocationInContext(DefaultDelegateInterceptor.java:90)
at org.camunda.bpm.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:62)
at org.camunda.bpm.engine.impl.util.DecisionEvaluationUtil.invoke(DecisionEvaluationUtil.java:99)
at org.camunda.bpm.engine.impl.util.DecisionEvaluationUtil.evaluateDecision(DecisionEvaluationUtil.java:86)
at org.camunda.bpm.engine.impl.dmn.cmd.EvaluateDecisionCmd.doEvaluateDecision(EvaluateDecisionCmd.java:72)

@Satya_Kumar, I guess that you see this failure because you’re not using Camunda BPM version 7.13.0, right?

BTW: it would be nice to know if something is working for you or not.

Upgraded to latest camunda version.

Request Body :
{
“variables” : {
“packages” : {“value” : [“Lunch”,“Drink”], “type” : “json”}
}
}

Response Code 400:
{
“type”: “InvalidRequestException”,
“message”: “Must provide ‘null’ or String value for value of SerializableValue type ‘json’.”
}

Decision_Packages.dmn (1.5 KB)

I think that the value must be a string. So, you need to pass the JSON array as string.

{
“variables” : {
“packages” : {“value” : "[\“Lunch\”,\“Drink\”]", “type” : “json”}
}
}

Thanks Philipp. It worked
Here are the details.
Rest-API :
RequestBody
{
“variables” : {
“packageList” : {“value” : [“Dinner”,“Lunch”]}
}
}

Response :
[
{
“price”: {
“type”: “Integer”,
“value”: 130,
“valueInfo”: {}
}
}
]
Components Version :
Modeller Version 4.0.0 (4.0.0.5956)
Engine : 7.13.0

Attached is the .dmn diagram.
Decision_Packages.dmn (1.5 KB)

1 Like

Hello,

I want to test with this file but since I have the new version it gives me this error

ENGINE-22004 Unable to transform DMN resource ‘Decision_Packages.dmn’. [deploy-error]

it doesn’t matter what decision table you load. can you tell me what may be causing this error.

Hello Satya, @Philipp_Ossler
can we use containsAll(“LUNCH”,“DRINK”,“DINNER”) in case we want the condition to be - input json contains all of the row values.

I want the match to happen only if we have all the strings in both the json and the row.
appreciate your help.

1 Like

Hi @prityV,

it sounds that you want to use the same expression as mentioned above:

every package in packages satisfies list contains([“Lunch”, “Dinner”,“Drink”], package)

Does this work for you?
Do you have a different requirement?

1 Like

Thanks Philipp,

I am using the below expression:
every x in [“Lunch”,“Dinner”] satisfies list contains(packages, x)

it solves the problem except below scenario :
-where the input list contains something extra that isn’t in the specified list.
packages: {Lunch, Dinner} ----works
packages: {Lunch, Dinner, breakfast} ---- doesn’t match even though it has lunch and dinner.

not sure if i am missing something.
Appreciate your help.

You could check the size of the list.

count (packages) = count([“Lunch”,“Dinner”]) and every x in [“Lunch”,“Dinner”] satisfies list contains(packages, x)

Does this work for you?

Hi @Philipp_Ossler,

I’m trying to pass an array as an input in the above format via REST API. It gives me the following error. test.dmn (3.7 KB)

500 Internal Server Error
{
“type”: “RestException”,
“message”: “Cannot evaluate decision testMapper:1:3ef6e1ff-b65e-11eb-983a-acde48001122:
Exception while evaluating decision with key ‘null’”
}

Camunda Modeler: 3.7.3
Process Engine : 7.12.0

Hi @Philipp_Ossler, I figured my mistake.

It’s the engine. I’m on 7.12.0 and it works on 7.13.0 with

org.camunda.bpm.dmn.feel.scala - FEEL/SCALA-01001 Spin value mapper detected