LotusScript Room Reservation Function - Solution!

After spending about a week searching the forums, going over the CS libraries with a fine tooth comb, and banging my head on my desk, I developed the following function to create and Cancel room reservations. I use this to reserve rooms from a corporate event calendar application “Event DB”. The code that calls this function check the availability of the room first using the session.FreeTimeSearch function.

I am also working on invitation/appointment creation functions for users to add/remove events to/from their calendars. I may post those as well once they are polished since it is obvious that there is a need for them based on the number of posts on the subject.

Function Reservations(Doc As NotesDocument, Cancel As Boolean) As Boolean

Dim DocColl As NotesDocumentCollection

Dim ApptDoc As NotesDocument

Dim DelDoc As NotesDocument

Dim StartDateTime As NotesDateTime

Dim EndDateTime As NotesDateTime

Dim RTItem As NotesRichTextItem

Dim Room As New NotesName(Doc.Location(0))

Dim Item As NotesItem

Dim Arr As Variant

Dim Idx As Integer



Set ApptDoc = CurDB.CreateDocument

Set StartDateTime = New NotesDateTime(Doc.StartDateTime(0))

Set EndDateTime = New NotesDateTime(Doc.EndDateTime(0))



With ApptDoc	

	.Form = "Notice"

	.ApptUNID = Doc.UniversalID	

	.AppointmentType = "3"

	.SendTo = Room.Abbreviated

	.StartDateTime = StartDateTime.LSLocalTime

	.StartTime = StartDateTime.LSLocalTime

	.EndDateTime = EndDateTime.LSLocalTime

	.EndTime = EndDateTime.LSLocalTime

	.Chair = "Events DB"

	.Principal = "Events DB"

	.From = "Events DB"

	.RequiredAttendees = Room.Canonical

	.ReservedBy = "Events DB"

	.tmpReservedBy = "Events DB"

	.ReservedFor = "Events DB"

	.ResourceName = Room.Canonical

	.ResNameFormat = Room.Abbreviated

	.SelectedRR = Room.Canonical

	.RQStatus = "T"

	.Purpose= Doc.Subject(0)

	.ResourceType = "1"

	.tmpResourceType = "1"

End With



Call ApptDoc.ReplaceItemValue("$CSVersion", "2")

Call ApptDoc.ReplaceItemValue( "$PublicAccess", "1")

Call Apptdoc.ReplaceItemValue("$NoPurge", EndDateTime.LSLocalTime)

If Cancel Then

	Call Apptdoc.ReplaceItemValue("NoticeType", "C")

Else

	Call Apptdoc.ReplaceItemValue("NoticeType", "I")

End If



Call ApptDoc.Send(False)

End Function

Subject: LotusScript Room Reservation Function - Solution!

nice post, have you found a way to save and send the meeting to recipients, as I cannot get that part to work