# Process array with objects in rule task

**URL:** <https://forum.camunda.io/t/process-array-with-objects-in-rule-task/41158>\
**Category:** Discussion & Questions\
**Tags:** process-engine\
**Created:** [November 22, 2022, 12:43pm UTC](https://forum.camunda.io/t/process-array-with-objects-in-rule-task/41158 "2022-11-22T12:43:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yakiv\_Stoikov](https://forum.camunda.io/user_avatar/forum.camunda.io/yakiv_stoikov/32/23106_2.png) [@Yakiv\_Stoikov](https://forum.camunda.io/u/Yakiv_Stoikov)\
**Post date:** [November 22, 2022, 12:43pm UTC](https://forum.camunda.io/t/process-array-with-objects-in-rule-task/41158/1 "2022-11-22T12:43:36Z")

</div>

I have a request body:

```auto
{
 "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:

```auto
{
    "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](https://forum.camunda.io/uploads/short-url/9lEkAmfyVUziXxsT4irAiBJsamI.dmn) (5.4 KB)  
[PassiveCountry.dmn](https://forum.camunda.io/uploads/short-url/kkKlanAU70Za4pORd34itMzlHTN.dmn) (4.5 KB)  
[PersonsData.bpmn](https://forum.camunda.io/uploads/short-url/nlkKP9aZXaUygSOJP0sil5ExA4N.bpmn) (3.9 KB)

---

<div class="post-metadata">

**Author:** ![StephanHaarmann](https://forum.camunda.io/user_avatar/forum.camunda.io/stephanhaarmann/32/21924_2.png) [@StephanHaarmann](https://forum.camunda.io/u/StephanHaarmann)\
**Post date:** [November 23, 2022, 6:34am UTC](https://forum.camunda.io/t/process-array-with-objects-in-rule-task/41158/2 "2022-11-23T06:34:38Z")

</div>

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:

 ![image](https://forum.camunda.io/uploads/default/original/3X/6/d/6df748710f0875c06845aeec4480a715da152d32.png)  
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.

---

<div class="post-metadata">

**Author:** ![Yakiv\_Stoikov](https://forum.camunda.io/user_avatar/forum.camunda.io/yakiv_stoikov/32/23106_2.png) [@Yakiv\_Stoikov](https://forum.camunda.io/u/Yakiv_Stoikov)\
**Post date:** [November 23, 2022, 12:32pm UTC](https://forum.camunda.io/t/process-array-with-objects-in-rule-task/41158/3 "2022-11-23T12:32:59Z")

</div>

@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”.

 ![image](https://forum.camunda.io/uploads/default/original/3X/5/1/5180ba457fb9382f4384e61d23cdfd60d748b8e2.png)

---

<div class="post-metadata">

**Author:** ![StephanHaarmann](https://forum.camunda.io/user_avatar/forum.camunda.io/stephanhaarmann/32/21924_2.png) [@StephanHaarmann](https://forum.camunda.io/u/StephanHaarmann)\
**Post date:** [November 23, 2022, 2:40pm UTC](https://forum.camunda.io/t/process-array-with-objects-in-rule-task/41158/4 "2022-11-23T14:40:35Z")

</div>

@Yakiv_Stoikov, you have different options:

1. You could try writing a [completion condition](https://docs.camunda.org/manual/7.9/reference/bpmn20/tasks/task-markers/#multiple-instance), 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](https://forum.camunda.io/uploads/short-url/9tPwhmBrjb5kNQ7FY1kBJY2D3FS.bpmn) (6.8 KB)

---

<div class="post-metadata">

**Author:** ![Yakiv\_Stoikov](https://forum.camunda.io/user_avatar/forum.camunda.io/yakiv_stoikov/32/23106_2.png) [@Yakiv\_Stoikov](https://forum.camunda.io/u/Yakiv_Stoikov)\
**Post date:** [November 24, 2022, 9:35am UTC](https://forum.camunda.io/t/process-array-with-objects-in-rule-task/41158/5 "2022-11-24T09:35:20Z")

</div>

@StephanHaarmann thank you again!! It works!

---

<div class="post-metadata">

**Author:** ![system](https://forum.camunda.io/uploads/default/original/3X/5/8/58d50142eacca605d35cb1ef9e6b86ae85f49436.png) [@system](https://forum.camunda.io/u/system)\
**Post date:** [January 31, 2024, 10:33am UTC](https://forum.camunda.io/t/process-array-with-objects-in-rule-task/41158/6 "2024-01-31T10:33:18Z")

</div>

Closed on January 31, 2024, 10:33am UTC


