Cast association to object in XPath

0
I’m trying to iterate through a list and count each instance of a particular association. My issue is when I write an XPath constraint I cannot test for equality because I am comparing type String to type association. Is there a way to cast the association to a string or another way to go about this. Here is my microflow . And I have attached a picture of my domain model below. I am checking for instances each buyer appears in a transaction (i.e. Walmart – 4 transactions, Costco – 6 transactions)  
asked
1 answers
0

The most efficient way is to create an OQL-command for that. Download the OQL from Appstore, in your micrflow create an variable containing the OQL-command and execute the OQL command:

SELECT <yourmodule>.Buyer.Name,COUNT(*) as NumberOfTransactions
FROM  <yourmodule>.Transaction
GROUP BY  <yourmodule>.Buyer.Name

Make it return a list of Name, NumberOfTransactions. 

if you are not comfortable with OQL, then do it in a microflow, but the other way around compared to your current microflow: loop over each Buyer and count the number of tranasctions. See this microflow:https://modelshare.mendix.com/models/f4aa2b3f-5cad-4d09-a5b9-6f70384ebaa2/su-b-employee-get-number-of-employees-per-oganization

 

A third way is to add a calculation-attribute to Buyer, call NumberOfTransactions an attach your calculation-microflow to it. Then you only have to read the Buyer’s attribute. Be careful not to have your app calculate it more then necessary. 

answered