validation problem

0
Still pretty new to Mendix and I didn't get an answer on my previous question, maybe I should rephrase it: On this screen I am trying to connect a course (Bedrijfsadministratie) to a teacher (Roel Hagedoorn) for some group (AA1A) which I can select from the dropdown menu's (the teacher I get from selecting a datagrid and the listview I added just to make it check it visually, it will be removed later on): I want to try to make sure that I get a validation message when I select (for this teacher) the same course for the same class that it will be a duplicate. How can I make this validation the most easy way (I thought through a microflow, but not sure how to collect the data from the fields (the yellow listview will be removed later on, but that's the path where I collect the data from)).    Part of the Domain model where this happens (the entity DocentVakGroep is combining the 3 entities): Anyone can help me or give me pointers on how best to solve this?
asked
1 answers
0

The DocentVakGroup is the key here. See the example microflow here:

 

 

Pass the DocentVakGroup object you want to check to this microflow. Retrieve the other three objects first. Then the key part to retrieve other DocentVakGroup objects with references to the same other objects.

Do a retrieve of DocentVakGroup with something like the following XPath constrained

[id != $DocentVakGroup]
[MyFirstModule.DocentVakGroup_Klas/MyFirstModule.Klas/Naam = $Klas/Naam]
[MyFirstModule.DocentVakGroup_ActiefDocent/MyFirstModule.Docent/Achternaam = $Docent/Achternaam]
[MyFirstModule.DocentVakGroup_Vak/MyFirstModule.Vak/Naam = $Vak/Naam]

The first line makes sure that you do not retrieve the same object as the object you want to check.

Do note that you want to make this check on unique stuff. If you have more teachers with the same name you are in trouble. But you probably get the meaning. If this retrieve is empty create the object otherwise give a message that the combination already exist.

Regards,

Ronald

 

And the res

 

answered