I’ve deployed the below DMN model. In the hit policy selected ‘Collect’ with ‘Count’ operator.
DMN XML Definition:
<definitions xmlns="http://www.omg.org/spec/DMN/20180521/MODEL/" id="definition_6f84d420-6db7-11ea-a029-005056011ac8" name="DiscountTable" namespace="http://www.flowable.org/dmn"> <decision id="DiscountTable" name="DiscountTable"> <description>DiscountTable</description> <decisionTable id="decisionTable_6f84d420-6db7-11ea-a029-005056011ac8" hitPolicy="COLLECT" aggregation="COUNT"> <input label="Category"> <inputExpression id="inputExpression_1" typeRef="string"> <text>Category</text> </inputExpression> <inputValues> <text>"bronze","silver","gold"</text> </inputValues> </input> <output id="outputExpression_2" label="Discount" name="Discount" typeRef="number"> <outputValues> <text>"5","10","15","20"</text> </outputValues> </output> <rule> <inputEntry id="inputEntry_1_1"> <text><![CDATA[== "silver"]]></text> </inputEntry> <outputEntry id="outputEntry_2_1"> <text><![CDATA[10]]></text> </outputEntry> </rule> <rule> <inputEntry id="inputEntry_1_2"> <text><![CDATA[== "bronze"]]></text> </inputEntry> <outputEntry id="outputEntry_2_2"> <text><![CDATA[15]]></text> </outputEntry> </rule> <rule> <inputEntry id="inputEntry_1_3"> <text><![CDATA[== "gold"]]></text> </inputEntry> <outputEntry id="outputEntry_2_3"> <text><![CDATA[20]]></text> </outputEntry> </rule> <rule> <inputEntry id="inputEntry_1_4"> <text><![CDATA[== "silver"]]></text> </inputEntry> <outputEntry id="outputEntry_2_4"> <text><![CDATA[10]]></text> </outputEntry> </rule> </decisionTable> </decision> </definitions>
When we execute this decision execute API with the input variable category as ‘silver’ we are getting the output as count as ‘2.0’
decision execute API Input:
{
“decisionKey”: “DiscountTable”,
“inputVariables”: [ {
“name”: “Category”,
“type”: “string”,
“value”: “silver”
}]
}
decision execute API result:
{
“resultVariables”: [
[ {
“name”: “Discount”,
“type”: “double”,
“value”: 2.0
}]
]
}
As from the flowable documentation, The Collect hit policy count gives the result the number of distinct outputs. here in our case for the silver category, we have the two outputs of the same value ‘10’.
In that case, the count should provide the value as ‘1’ instead of ‘2’. If the result ‘2’ is correct then how the count operator will work. Wll it counts all the occurrences or only distinct output values?.