How do I count the number of Entity database rows with a specific attribute value

0
Hi,  Not sure if the title made any sense.  I have an Entity called MatterDetail which contains certain data including an attribute based on an ENUM with 3 values, Draft, Submitted, and Complete.  I would like to count the number of database rows that have submitted as the attribute value.  Can anyone help with the best way to do this please?  You may need more info off me so let me know.   Wasn't sure if I needed to create a new Entity that would hold these values but I'm not even sure how to do that! Cheers
asked
5 answers
1

You can create a microflow, in that microflow retrieve all the MatterDetail objects with the status 'submitted' after this you can do a count of MatterDetail list, the count gives you back the number of entities.


See https://docs.mendix.com/refguide/aggregate-list

answered
1

If I am reading the question correctly, you want to count how many of the MatterDetail objects for each of the 3 Enum values.

If that is correct, you can use a microflow to retrieve from the database all of the MatterDetail objects. After that use the List Operations "Filter" to get 3 new lists based on the different Enum values (ie, modulename.EnumValue.Draft). You can then use the Aggregate List activity to Count each of these lists and either display a message on screen with those counts or log them to the database. 

Another option is to create a datagrid and have a search function on it for that Enum value. There you could see how many records return for each.

answered
0

Brilliant, thank you both for the prompt reply.  I should be able to do what I want to do now.

answered
0

Sorry, last point on this.  So I have the count of Submitted and Draft which I need, do I have to create a new object/entity to store them in order to return them both at the end of the Microflow?  I'm thinking of having this flow run automatically as well when you load the app, so im assuming an entity would be best so it can store the results.

answered
0

Yes, that would be the easiest way to capture the information. You would only need to create 1 object from the new entity  the first time and just update the count attributes needed. The next time the microflow runs you will retrieve the first of that entity then change it.

answered