Newbie here. I’m attempting to create appointment booking functionality in my app using @Loqode ´s advanced booking app tutorial (which is amazing btw!): 🎓 Advanced Booking App Tutorial (Step-By-Step)
However, I’m kind of at a standstill because in @Loqode’s approach, the person making the appointment chooses which admin user they want to book the appointment with, but I need the bookings assigned automatically and evenly between the admin users that are available for that specific slot.
At the same time, the person making the booking should only see the timeslots where at least one of the admin users have availability. If only one admin user is available for a specific slot, then naturally that user should be assigned.
Does anyone have any suggestions or pointers as to how I can solve this please? Any help is much appreciated! 
Can you explain more on how you define “evenly” here?
Wouldn’t an admin who has already had that slot booked be eliminated from the list in contention to be assigned?
In that case, maybe you can just pull a random admin from the available list for a specific slot?
Yes, obviously an admin who already has that slot booked cannot be assigned.
By evenly, I mean that the system assigns an available admin by distributing appointments evenly among the available admins by checking their current weekly total of appointments at any given time. Simply randomizing it could potentially lead to an admin getting several more appointments than others, but by always checking which admins have the lowest amount of appointments and then assigning the appointments one by one to admins with the fewest appointments, you avoid getting admins that have 2-4 more appointments than others because of randomization.
Is that possible, and how do you suggest doing it? If not, how do I pull a random admin, as a last resort?
Scanning through the tutorial video very quickly, does that mean you have created a custom form instead of a native form? If so, you should be able create a relation in the admin table linking to the bookings table, followed by a Rollup to count the number of bookings for each admin. Then in your form table, create a query of the admins, sorting by the Rollup count. Finally use a single value column to grab the first admin from the query column. If done correctly, it should be the admin with the lowest number of bookings. That admin can then be passe along when the form is submitted.
1 Like