How can I restrict travel bookings based on place and trip date?

How can I restrict travel bookings based on place and trip date?

In the following code, added to the on add -> validate block of the Script tab, the Booking_Form restricts entries based on the following conditions:

  • Only four bookings allowed for a specific place on a day. If the number of bookings (with Place & TripDate same as the input Place & TripDate) is equal to 4, the alert message will be displayed and the record will not be submitted. 
  • The same person cannot book on consecutive weekends. The consecutive weekend days (Saturday and Sunday) are calculated based on the current Trip date. If the same person has booked on those dates, the alert message will be displayed and the record will not be submitted.  

            if (count(Booking_form[(Place == input.Place && TripDate == input.TripDate)])  ==  4)
{
alert "Booking full on this date. Please try some other date";
cancel submit;
}
else if (input.Date_1.getDayOfWeek() >= 6)
{
previous_weekend1 = (input.TripDate - '1W:0D:0H:0M:0S');
previous_weekend2 = (input.TripDate - '0W:6D:0H:0M:0S');
if ((count(Booking_form[(Name == input.Name && TripDate == previous_weekend1)]) != 0) ||
(count(Booking_form[(Name == input.Name && TripDate == previous_weekend2)]) != 0))
{
alert "You cannot book consecutive weekends";
cancel submit;
}
}
    • Related Articles

    • Introduction to Zoho Bookings

      What is Zoho Bookings? Zoho Bookings, at its core, is an online tool your clients can use to book appointments with you. It gives you complete control over managing those scheduled events. Any service, such as a salon or clinic, requires a mutually ...
    • How can I restrict property bookings based on arrival and departure dates?

      In the following code, the Property_Bookings form restricts bookings based on the Arrival and Departure dates for a specific property. For instance, if a booking is made for property named C54 between 1st and 9th Jan, the form validation should check ...
    • Online meeting integration with Zoho Bookings

      Zoho Bookings is online booking software that helps small businesses manage appointments with customers and clients efficiently. With the online meeting integration of Zoho Meeting in Zoho Bookings, you can create and share booking links with your ...
    • How can I restrict entries to my Registration Form based on a given date?

      Assume you have a Registration form to register for a specific course and the registration is open till 30th Dec 2009. To restrict entries from being submitted after this date, use the zoho.currentdate variable within the on add -> on validate block ...
    • Date-field Autoresponder

      Understanding date-field autoresponder Date-field based autoresponders are a series of automated messages that are sent to contacts based on the date in the date field associated with them. Wishing customers happy birthdays and anniversaries are ...