G’day, I’d like to know how to use DMN with list of strings or array in the input variable eg. A & B
{
“variables”: {
“name”: {
“value”: [
“A B”
],
“type”: “Array”
}
}
}
I need an output based on an array of input. So if A & B are present, I need an output
Here is an example using the FEEL function contains to check the content of your text.
Depending on your requirement you may want to adjust the rules and evaluation policy (First)
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="https://www.omg.org/spec/DMN/20191111/MODEL/" xmlns:dmndi="https://www.omg.org/spec/DMN/20191111/DMNDI/" xmlns:dc="http://www.omg.org/spec/DMN/20180521/DC/" id="Definitions_093gp5v" name="DRD" namespace="http://camunda.org/schema/1.0/dmn" exporter="Camunda Modeler" exporterVersion="4.3.0">
<decision id="MyDecision" name="My Decision">
<decisionTable id="DecisionTable_11mhzt9" hitPolicy="COLLECT">
<input id="Input_1" label="My Text">
<inputExpression id="InputExpression_1" typeRef="string">
<text>myText</text>
</inputExpression>
</input>
<output id="Output_1" name="Result" typeRef="string" />
<rule id="DecisionRule_14ioo8t">
<inputEntry id="UnaryTests_0ltytx1">
<text>contains(cellInput, "A")</text>
</inputEntry>
<outputEntry id="LiteralExpression_1710kw6">
<text>"A"</text>
</outputEntry>
</rule>
<rule id="DecisionRule_12feoli">
<inputEntry id="UnaryTests_0ulkuu2">
This file has been truncated. show original
3 Likes
I tried your solution and found the problem
If I pass the variables value as folllows
{
“variables”: {
“myText”: {
“value”: “CA A HA”,
“type”: “String”
}
}
}
Then my result includes 3 values
“A”
“A”
“A”
I want evaluation just only “A” → “A”. Otherwise, “AB” or “HA” → is not satisfied.
How can I do it?
With “CA A HA” you should get only a result with one entry: “A”
With “CA B A HA” you will get a result containing three entries because all rules apply:
[{“Result”:“A”},{“Result”:“B”},{“Result”:“A and B”}]
If you want only a single value then you need to switch to a suitable hit policy:
https://docs.camunda.org/manual/latest/reference/dmn/decision-table/hit-policy/
1 Like
I try this solution, it worked for me
Add list contains(code, “101”), list contains(code, “102”) to each row of decision table.
Preparing request data as the following:
"code": {
"value": ["101","102","103"]
},
The result will shows all outputs which satisfy with input 101 and 102.
You can also test the solution using POSTMAN
Hope to help you!