Refer to object of same entity

Hi all! Is it possible to create a reference between two objects of the same entity? I have a product database system, where I want the possibilty to connect some of the products to other products. Is this possible? And if yes, how? I can't seem to connect two objects of the same entity to eachother. Kind regards and many thanks in advance!
4 answers

Yes it is. Double click on the entity, go to the associations tab. Add a new association pointing to the same entity.


Although Mendix supports self associations (i.e. an associations between two objects of the same entity) I would not recommend this. Such associations are difficult to navigate in both directions (in fact for non-persistent entities it is impossible). What I would use instead is either:
1) an additional link entity with two associations e.g. from-to or parent-child, or

2) soft link the objects by using AutoNumbers and storing them as longs.

Hope this helps,


PS. The second approach has the limitation that  mendix does not recognize this association and so you lose some functionality e.g. you can not easily show an attribute from an associated entity in a form.


case 1) 

case 2)



You should be able to that. Open the Enitty on the Tab associations and select the entity you would like to associate, it can be also the same object. Possibly, you will have some trouble because the arrow is not right visible because it is too small or overlapped from the entity self.


Thanks all! All answers already helped a lot. 

But now I run into another problem. How can I set this association in a microflow.

I added an entity in my domain model to connect the different objects. But I can't get the two objects as seperate parameters in my microflow.

I added two screenshots to clarify what I mean. I think I'm super close. But I can't figure out the final step of calling the association in a microflow.