• JOANNE CONLU
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
I'm a new Admin, not a Developer. We host events by renting out our spaces and have resources (golf carts, tables, chairs etc); think of us as a hotel/venue on campus. I want to prevent overbooking these resources. Ie, we only have 2 golf carts, we don't want to book more than 2 on a given day. How can I prevent this? We're using Classic. Thank you!
I'm a new Admin, not a Developer. We host events by renting out our spaces and have resources (golf carts, tables, chairs etc); think of us as a hotel/venue on campus. I want to prevent overbooking these resources. Ie, we only have 2 golf carts, we don't want to book more than 2 on a given day. How can I prevent this? We're using Classic. Thank you!
Hi All, 

I am trying to prevent people double booking a piece of equipment out. The user uses the custom object Booking Request to book out equipment for certain dates. 
For example Mike books equipment1 from the 22/06/2016 until 24/06/2016, then someone else wants to book the same piece of equipment from the 23/06/2016 until 25/06/2016 but should not be allowed as it is already booked.

I have created the following trigger which is working if someone enters the same start date, but how do i stop the record saving if they book in between the start and finish date? Any help greatly appreciated.

trigger DuplicateBookingTrigger on Booking_Request__c (before insert, before update) {
  for (Booking_Request__c br:Trigger.new)
  {
      List<Booking_Request__c> b=[select ID from Booking_Request__c where Equipment_Code__c=:br.Equipment_Code__c and Start_Date__c=: br.Start_Date__c and Finish_Date__c=: br.Finish_Date__c];
      if(b.size()>0)
      {
          br.adderror('The equipment selected is already booked for this date');
      }
   }