Validate Unique column in different entity

0
Hi All, I have two entity: 1. Area entity that have column AreaId as unique 2. Cluster entity that have column ClusterId as Unique I join those entity which able to create same AreaId, as long the cluster selected is different. tell me that step by step in Mendix to make it possible.  
asked
1 answers
0

On the save button retrieve the MArea objects from the database where your xpath looks something like:

[AreaID = $MArea/AreaID][id != $MArea] [MArea_Cluster = $MArea/MArea_Cluster]

The first part is to get the Area with the same name.

The second part is there to prevent retrieving the record on the page.

The third part makes sure to get MAreas with the same selected cluster.

Now if the database retrieve action returns any records there already is an Area with the entered ID for the selected cluster and you can provide validation feedback on the AreaID text widget.

If the retrieve does not return data the cobination is unique and therefore in your situation valid.

answered