Process array with objects in rule task

I have a request body:

{
 "variables":{
    "persons": 
        {
            "type": "Object",
            "value":  "[{\"country\":\"USA\",\"businessId\":\"CUS-1\",\"age\":15,\"state\":\"Alabama\",\"major\":false},{\"country\":\"USA\",\"businessId\":\"CUS-1\",\"age\":20,\"state\":\"Alabama\",\"major\":false}]",
            "valueInfo": {
                "objectTypeName": "java.util.ArrayList",
				"serializationDataFormat": "application/json"
			}
    },    
    "businessPartner": {
        "type": "Json",
        "value": "{\"businessId\":\"BP-1\",\"businessUnit\":\"NED\",\"servicingUnit\":\"servicingUnit\",\"bookingCenterCurrency\":\"USD\"}",
        "valueInfo": {
				"serializationDataFormat": "application/json"
			}
    }
  },
  "withVariablesInReturn": true
}

And I want to check every object from the value “persons”. I add some structure in my DMN, but can’t separate objects. Get responses like:

{
    "type": "DmnEngineException",
    "message": "DMN-01005 Invalid value '[15, 20]' for clause with type 'integer'.",
    "code": null
}

What do I need to add to my DMN?
MajorityRule.dmn (5.4 KB)
PassiveCountry.dmn (4.5 KB)
PersonsData.bpmn (3.9 KB)

The variable “persons” refers to the array storing all persons.
To process each person individually, you can use the element variable in the multi-instance business rule task:


If you configure the task as depicted above, the business rules task will be executed for each person. Each instance of the business rule task can access the variable person which contains the person for the respective iteration.

2 Likes

@StephanHaarmann, thank you!
Maybe you could help me with one more question? If I want to stop the process if get in some person FALSE result, what is the best solution for this?
Now I am getting results only of the last person. But I want to get FALSE in DMN MajorCheck if even only one person matches to “false”.

@Yakiv_Stoikov, you have different options:

  1. You could try writing a completion condition, that evaluates to true as soon as one result is FALSE
  2. You can add post-processing to detect if there is at least one. Therefore, I would
    a. Add a multi-instance subprocess
    b. add the Business Rule Task to this subprocess
    c. within the subprocess, add a script or service task that stores the result of the decision in an array
    d. add an output mapping to the subprocess that checks, whether one of the decision instances returned false.

The process would be something like this (disclaimer, I did not run it, but it should show the idea):
PersonsData (1).bpmn (6.8 KB)

1 Like

@StephanHaarmann thank you again!! It works!