Double booking check

Hi,

I am building an app to facilitating share a car with eachother and reserving the car.
I have build an calendar assigned to a sheet where the user adds a reservation (one or multiple days with start date + time and end date + time). I am wondering if and how its possible to prevent double bookings. I have seen some solutions for time slots, but I want to make it impossible (or at least give a warning via hint-component) to book the car within another booking.

Is this possible? And how can I achieve it?

Hi @Jonne_Paes

Unfortunately there is no native way of blocking slots that are already taken in Glide.

Here is what I would try :

  • Create a custom form for the booking process where user selects car, start and end date
  • Do a query to the reservations table, filtering by : 1) the id of the selected car, 2) check if there are reservations starting before the selected end date OR 3) if there are reservations with and end date after the selected start date.
  • Use an IF Then Else to block the submission of the form is there are results in the query

It might be tricky to play with comparing the dates but I think it could work.

The only thing is that it might make the user think the car is not available at all in the selected period. For ex, letโ€™s say a user wants to book from 01/01/2024 to 02/01/2024. The car is available but someone has already a booking starting on the 01/31/2024, so before the selected end date of the user completing the form, so itโ€™ll block the user from booking whereas the car was only unavailable 1 day in the requested booking window.

So if this works, it would be great after to find a way to retrieves start and end dates of the current bookings and display infos to the user so he can re ajust his booking.

3 Likes