Data validation in Trial

2
I'm new to Mendix. Just deployed my first application. The domain model basically consists of two entities (Organisation and Person) with an intermediate entity (Contact). This Contact entity has associations towards both Organisation and Person, and has one attribute of its own (Biblithecaris - this indicates whether the person has the role of bibliothecaris for the organisation). In my application one person can be assiocated (via Contact) multiple times to the same organisation. How can I restrict this. In other words: how can I declare a Unique Constraint on the associations towards Organisation and Person?
asked
2 answers
2

Before setting the association to an organization of a person (through contact), you could first retrieve all organizations that have a contact with a reference to that person and then simply don't set it and show some info instead when the retrieved list holds items.

(Or do it the other way around if you set persons to an organization)

You will need to build custom forms and use microflows for this though.

answered
0

If contact only has the Bibliothecaris attribute, consider to move that to person and remove the contact. Between person and organisation you can either have a reference set (persons can work in multiple organisations and organisation can have multiple persons as employee). Or use a reference (organisation can have multiple persons as employee) just the way you want to model.

I presume you need the reference set and this solves your problem because a person cannot be added more that once to an organisation.

answered