Select association with highest attribute value using a microflow
Hi, I have patient and a doctor and I want to automatically assign the patient to the doctor who has the most room (integer) left. It would be great if the name of the doctor then would appear on the right of microflow button. http://imgur.com/uxb3gcB Thanks in advance!
A solution could be creating a custom 'New' (microflow)button, for when you want to create a new patient object. This microflowdoes:
create a new patient object
retrieve the doctor that hast the most room left
make an association between the two.
In the data view you would not need 'Select Doctor' button any more. In that space you could automatically display the doctors name.
Is this what you're looking for?
Thank you for the suggestion.
However, one user creates the patients and another user screens the patients and assigns them to a doctor.
I hope there is a solution.
Add a Doctor dataview to your page, inside the Patient dataview. It should retrieve the Doctor over association. Make sure you add the Doctor's name in there as a TextBox.
Now your "Select Doctor" microflow button should do the following:
Parameter should be Patient (should happen by default)
Retrieve from database a list of doctors, only the first one, and sort by your capacity integer (descending)
Change the Patient, add the association to the selected doctor, refresh in client
Decrement the Doctor's capacity integer by 1, commit and refresh in client
I think that should do it! Executing the microflow should associate the doctor and display his/her name on the screen.