Calendaring

Hi,
I have a requirement where user has to book rooms for some Briefing. At present Iam using a calendar to see the availability of the room for the date and time. But I want a way where when I enter the date and time, i should be given a message that the Room is available or not for that time and date. I tried using getdocumentbykey in script, taking the room name, date, starttime and endtime as key. But if the time say i am looking for is 10am to 12pm and if the room is booked from 10.30am tehn it fails and says the room is available. any suggestion is appreciated

Rajen
RajenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RajenAuthor Commented:
Edited text of question.
0
ArunkumarCommented:
Hi Rajen !

Sometime back I was having a similar problem and the following was the solution I gave to the customer.
You should go for a lengthier script.  Lemm give you the logic.

SORRY I dont have that code now.

Walk through the destination view with a do while last document. The view from which you are currently getting documentsbykey.  

First compare the date you have with that of the date on the documents that are walked through.  

sourcedate = targetdate then go in for the field comparisons

Your starttime should not fall between the timerange of the walked documents. So as your end time.

if
sourdestarttime > targetstarttime and sourcestarttime < targetendtime then
you have a conflict.

Similarly for the endtime
sourdeendtime > targetstarttime and sourceendtime < targetendtime then
you have a conflict.

When ever the date matches and the time
conflicts you are sure that the room is unavailable.

Good Luck !

Love,
Arun
0
RajenAuthor Commented:
Hi, Arun Can you send the code.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

ArunkumarCommented:
Working on it.  You will get it in a couple of hours.

:)
Arun
0
ArunkumarCommented:
Hi Rajen,
Please try the following code.  The variables you have to change are :

BOOKINGSDATABASENAME.nsf  --- The database name of the view from which you were trying the GetDocumentByKey
THEVIEWNAMEYOUWANTTOWALKTHROUGH ---  name of the view from which you were trying the GetDocumentByKey
STARTTIMEFIELDNAMEINYOURUIDOCUMENT --- start Time field name in your currentdocument
ENDTIMEFIELDNAMEINYOURUIDOCUMENT  ---  end time field name in your current document
STARTTIMEFIELDNAMEINYOURBOOKINGSDOCUMENT --- start time field name of the document that has to be checked
ENDTIMEFIELDNAMEINYOURBOOKINGSDOCUMENT  ---  end time field name of the document that has to be checked
DATEFIELDNAMEINYOURUIDOCUMENT  ---  date field in your current document
DATEFIELDNAMEINYOURBOOKINGSDOCUMENT  --- date field in the document that has to be checked.

The code is not tested.  But.....

:)
Arun

========================================    
     Dim ss As New notessession
     Dim ws As New notesuiworkspace
     
     Dim targetdb As notesdatabase    
     Dim view As notesview    
     
     Dim uidoc As notesuidocument
     Dim sourcedoc As notesdocument
     Dim targetdoc As notesdocument
     
     
     Dim sourcestarttime As Variant
     Dim sourceendtime As Variant
     
     Dim targetstarttime As Variant
     Dim targetendtime As Variant
     
     Dim sourcedate As Variant
     Dim targetdate As Variant
     
     Dim flag As String
     
     Set uidoc = ws.Currentdocument
     Set sourcedoc = uidoc.document
     
     sourcestarttime = sourcedoc.STARTTIMEFIELDNAMEINYOURUIDOCUMENT(0)
     sourceendtime = sourcedoc.ENDTIMEFIELDNAMEINYOURUIDOCUMENT(0)
     sourcedate = sourcedoc.DATEFIELDNAMEINYOURUIDOCUMENT(0)
     
     Set targetdb = New notesdatabase(ss.CurrentDatabase.Server,"BOOKINGSDATABASENAME.nsf")
     Set view = tardb.GetView("THEVIEWNAMEYOUWANTTOWALKTHROUGH")          
     Set targetdoc = view.GetFirstDocument
     
     flag = "Free"
     
     Do While Not (targetdoc Is Nothing)
         
          targetdate = targetdoc.DATEFIELDNAMEINYOURBOOKINGSDOCUMENT(0)
         
          targetstarttime = targetdoc.STARTTIMEFIELDNAMEINYOURBOOKINGSDOCUMENT(0)
          targetendtime = targetdoc.ENDTIMEFIELDNAMEINYOURBOOKINGSDOCUMENT(0)
         
         
          If sourcedate = targetdate Then
               
               If ((sourcestarttime >= targetstarttime And sourcestarttime <= targetendtime))  Or ((sourceendtime >= targetstarttime And sourceendtime <= targetendtime)) Then
                   
                    Messagebox "A room is already booked in the specified timeslot "
                   
                    Exit Do
                   
               End If              
               
          End If
         
          Set targetdoc = view.GetNextDocument(targetdoc)
         
     Loop
     
     If flag = "Free" Then
         
          Msgbox "No booking made to the room at the specified timeslot"
         
     End If

====================================
0
ArunkumarCommented:
As above....
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RajenAuthor Commented:
Hi Arun,
Thanks for your code
Rajen
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.