if(input.Schedule_Date_Time <= zoho.currenttime && input.Schedule_Date_Time < zoho.currenttime.addHour(1)) { alert "Booking can be done prior to 1 hour"; cancel submit; } if(!thisapp.Util.CheckAvailability(input.Staff_Name,input.Schedule_Date_Time,input.Schedule_upto)) { alert "The Time Slot You Booked is Not Available or Your Time Exceeds Staff's Availability Time. <br> Please Try Other Time Slots."; cancel submit; } getAppointments = Appointment_Booking[ID != 0] sort by Added_Time desc; if(getAppointments.count() == 0) { input.Booking_Id = "0001"; } else { num = getAppointments.Booking_Id.toLong(); num = num + 1; input.Booking_Id = leftpad(num.toString(),4).replaceAll(" ","0"); }