Use a microflow seems like the way to go.. don't use a microflow to calculate the number of students otherwise the value isn't stored in the db and can't be used using a retrieval. Create an attribute which is filled with a overbookpercentage (float/currency > number of students:capacity)
if list is empty goto step below otherwise return list
Thanks for the fast answer. But it isn't totally clear for me.
How to calculate the number of students then, if not to use the microflow? It is indeed true that when I use in the XPath that I want all doctors for where capacity > number of students he gives an error.
And what do you mean with 'sorting where the capacity > number of students?'
And what must be the end node? What I have done now is making an attribute in student that I call mentor. I chose for this attribute the microflow as stated above and so the end node will be a list of doctors. But I do not know whether this is right.
When you commit a student entity, get the associated mentor, for the mentor retrieve the number of students associated and place that value in a integer attribute on the mentor and calculate the overbookpercentage. Make sure that after deleting a student you do the same. This way you will have a field in your database with the number of students and a overtime percentage for each mentor, which you can use with an xpath retrieval.
On the student form you can add the reference to the mentor and use a microflow to retrieve the list of mentor(s) as specified above. The microflow should return a list of objects (mentor objects), sorting needs to be done in the microflow because you're using a microflow.
When you change the existing mentor for a student it becomes tricky because the currently selected mentor may become unavailable. You could add the currently selected mentor to the list if not available.
Thanks for the answer.
One thing we still couldn't manage. We know what to do in this case, constrainting an association. We know that by clicking 'add' in the menu patient we will only see the doctors which are available. So we need an XPath on the association which says that (capacity - total assigned students) > 0. We know how to constraint an association in mendix by the XPath in the reference set selector option menu. But as you said we couldn't use attributes (total assigned students) in here which are calculated by a microflow. So indeed we may not calculate the total assigned students by a microflow. But how to calculate it then? Because when I say that the value of the totalassignedstudents isn't computed by the microflow but by database, it is possible to change the object of this value by a microflow. But this change isn't automatically when you assign a new student to a mentor. You need a 'compute-button' for this case. But this isn't what we want, we want that in every case the number of students which is assigned to a mentor is automatically computed.
What to do?