Count references

0
Hi, i have an “artikel” entity which references to itself. e.g. a pc contains a ssd, ram,.. all are articel. so the “artikel” pc in his form gets a list of reference articles which belong to this. It would be nice to know how many articels are referenced.       So i want to build a MF to take the sum of these referenced articles I would build up a list from the referenced Articels but i can’t find the helpful starting..   Can anybody help do calculate this?   many thanks!
asked
3 answers
1

Hi Torsten,

 

If I am understanding correctly, what you are trying to do is retrieve a list of referenced objects and count them.

 

This can be accomplished with two activities in your microflow.  First, use a retrieve activity to retrieve the list of associated objects.  Then, use an aggregate list activity to count the list of retrieved objects.  This will result in an integer which can be stored in an attribute on your original entity to keep track of the counted number.

 

A handy Mendix feature to know about, if the aggregate list activity is the only activity in you microflow that makes use of the retrieved list of objects, Studio Pro will detect this and merge them into a single query to the database in order to improve performance.

 

You can find more details in the documentation here: https://docs.mendix.com/refguide/aggregate-list/

 

Hope this helps

Danny

answered
1

oh sorry,sorry..

 

of yourse it works ;-)

i only had to connect the int..

thanks danny!!

answered
0

Hi Danny,

 

thanks for your answer.

I build the MF and after all i get my Count as “intCount”

But how to save this, as the Domainmodel only allows writing by the MF?

 

answered