Use count in an xpath expression (as source for a datagrid)

0
Hi Everybody! I am working on an app where I have a datagrid that needs to have its datasource from XPath. I want to show only Tourgroups with more than 5 registrations. I've been browsing the forums and docs and the most fitting option would be the count function, but I can't seem to get it working. I've included a screenshot of my domain model. There is a calculated attribute TotalParticipants, but I'm not allowed to select that in my Xpath constraint. How can I retrieve the desired data?
asked
3 answers
1

Hi Bart,

Calculated attributes are not stored in the database which is the reason why you cant use them in xpath constraints or use the aggregate functions on them. Instead they are calculated by a microflow when a user navigates to a page where it is being displayed. I would change your TotalCost and TotalParticipants to the data type Decimal in order to run the aggregate functions.

Once you change the data type for TotalParticipants your xpath would be this (if your datagrid is showing the tourgroup as the entity)

TotalParticipants > 5

 

answered
1

Another idea is to create a enum status or boolean on your Tourgroup that is triggered when your it reaches 5 or more registration. Then you can set your data grid's xpath to read.

[(insert_boolean_name) = true()]

answered
0

Hi Bart, 

You could use the xpath count function to count the connected regustrations https://docs.mendix.com/refguide/xpath-count 

Best, 

Mitchel 

answered