Iterate over an List with 100 Objects

1
Hello together, I retrieve over an Rest Call a list with over 100 Object with each 50 Elements of the same Variables by different time stamps. Is it Possible to Iterate over this list and count the same Variable for example: Object 1  First Variable      Value True Object 2  First Variable      Value False Object 3  First Variable      Value True   So that the Result is First Variable = 2 because of two true values ?? And this for more than One Variable.   Mendix Version 8.14.1   Thanks in advance.
asked
3 answers
3

Instead of iterating you could also use a List Operation ‘Filter’  on your list followed by a Aggregate List ‘Count’ action on your filtered list for the attributes you need.

answered
3

To take away the laborious work you could try to implement this in a java action.

You’ll need to loop through the attributes of the entity and use the following method to get the counts

retrieveXPathQueryAggregate

In the loop you can write the xpath constraint that will look something like

 "COUNT(//yourmodule.yourentity where ##### = true)"

Replace the #### with the attribute that is the current attribute in the loop. Then execute the above method to get the count and create an entity with a name value pair (2 attributes) to store the name of the attribute and the count in the value field. Then depending on your needs add these new records in a list and return the list from the java action to allow you to further process the data.

This might be an approach that could save you having to create 200 filter and count actions, but does require some java skills.

answered
0

This I right to do but 200 Filters and Counters for the list is a little bit laborious.

answered