i want a unique datetime combination with a other attribute but how?

Im a beginner with mendix and for school  i have to make a reservation schedule for classrooms. so a clasroom can have multiple dates and a date can have multiple classrooms    here you can pick a date and a room you want to select( i use a datetime widget from the appstore) the problem is that a classroom can be booked multiple times at the same date and time like here:and this should not be possible. And if i change the validation rule for date to be unique, this happens: if i select a other room that i want to reserve at 6/6/2018 at 10:00 it shows a error, this date and time is already used for a other room. so what i want is this: room KZ.D4.280 at 6/6/2018 at 10:00, if somebody else want to make e reservation for 6/6/2018 at 10:00 they have to choose a other room. is this possible?  
1 answers

You should use a microflow to check if the chosen time is available. Use an On Change microflow for this when picking the date and time. In the microflow do a retrieve off all the reservations. Loop over those and check if the picked date time lies inside of the reservation. You can use a statement like if $pickedDate >= $startdate and  $pickedDate <= $enddate then true. You should also do this for the picked enddate. Because the reservation could begin in a free slot but end in a slot with a reservation.

Then based on the outcome give a message to the user that the slot is not free or commit the reservation if it is.

Hope this helps.