Unable to Sum Array in FEEL

I am trying to sum the contents of an array in my DMN.

The ruleset:
stpRules.dmn (3.6 KB)

The input, stored in parameter fraudData:

{
  "customersName": "Test One",
  "customersNameCinBin": "1111111111",
  "customersAccountNumber": "11111111",
  "customersSortCode": "111111",
  "paymentDetails": [
    {
      "transactionDate": "2024-04-21T18:25:43-01:11",
      "transactionAmount": 250.00,
      "transactionType": "POS",
      "maskedPAN": "************1111",
      "paymentStatus": "Pending"
    }
  ],
  "pocDataPoints": {
    "isAnIncident": "false",
    "existingCasesInLastTwelveMonths": "0"
  }
}

In the DMN I have a literal function trying to determine the total of transactionAmount. Here is the function:

sum(fraudData.paymentDetails.transactionAmount)

The statement does not return a result, this is the main issue

This does not resolve correctly, even though the following resolves in the DMN testing tool: Try out and learn DMN FEEL - FEEL Playground

I assume I am doing something wrong with the variable fraudData. So in my DMN STP rules, I added some debug info. Here is the output when the rule is run in Camunda:

{
	"stpEligible": true,
	"tryingSumDirectly": null,
	"fraudData_paymentDetailsTransaction_amount": [
		"250.00"
	],
	"outputFromCalculateTotal": null,
	"theOriginalParamPassedIn": {
		"customersName": "Test One",
		"customersNameCinBin": "1111111111",
		"customersAccountNumber": "11111111",
		"paymentDetails": [
			{
				"paymentStatus": "Pending",
				"transactionType": "POS",
				"transactionAmount": "250.00",
				"transactionDate": "2024-04-21T18:25:43-01:11",
				"maskedPAN": "************1111"
			}
		],
		"customersSortCode": "111111",
		"pocDataPoints": {
			"existingCasesInLastTwelveMonths": "0",
			"incident": false
		}
	},
	"ruleMatched": 1
}
  1. Output from tryingSumDirectly is running the actual sum formula - result empty
  2. Output from fraudData_paymentDetailsTransaction_amount shows the transactionAmount resolves into an array, though it is a String even though my input is not String?
  3. Output theOriginalParamPassedIn shows that fraudData resolves successfully

Any help will be appreciated.

Pieter

Hi @PieterS

I tried it out on the feel playgound myself and it seems to work correctly for me as well.

Can you let me know exactly where you’re trying this expression and what version of the engine you’re using and any other information about the execution environment.

Thanks Niall. Am I handling process variable fraudData correctly? I see from your example that you added a parent node fraudData - its that what happens under the covers in the BPMN execution?

I try the expression twice, once in the literal expression, and also once in the dmn.

The execution occurs in a process which maps the input into variable fraudData, and it appears to map correctly.

This is all executing in Camunda 8.4

I had Java POJO that was modelled as private String transactionAmount;, which was the root cause of the issue.

1 Like

Thanks a lot for letting us know about the solution :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.