Subject: RE: Script Help Needed
This is older code, originally developed for Lotus Notes 4.5 so it may need a few updates for the current version of the calendar.
I see my code originally, had a Start and EndDate on fhe form, I think you have that also… So I’ve left my code alone. However, if not you should take the stuff from the earlier posting about taking the date and time as string and convert them to a NotesDate time.
I tried to strip out stuff you don’t need, I had various other options the on the form that you don’t need to see / worry about. Hope this helps?
On my form I have a field called StartDate - the date of a meeting and TimeRange (timerange picker) which gave you the start and end time of the meeting:
Dim db As NotesDatabase
Dim DBProfile As NotesDocument
Dim mailServer As String
Dim mailFile As String
Dim message As String
Set ws = New NotesUIWorkspace
Set s = New NotesSession
Set db = s.Currentdatabase
Set uiDoc = ws.Currentdocument
Set Doc = uiDoc.document
MailServer = s.GetEnvironmentString("MailServer",True)
MailFile = s.GetEnvironmentString("MailFile",True)
Dim Maildb As New NotesDatabase( mailServer, mailFile )
If Not Maildb Is Nothing Then
Set calDoc = New NotesDocument (Maildb)
Dim tr As NotesDateRange
Dim rtitem As NotesRichTextItem
Dim Subj As String
Dim Team As String
Dim sDate As New NotesDateTime( "" )
Dim eDate As New NotesDateTime( "" )
caldoc.Form="Appointment"
caldoc.Broadcast=""
caldoc.Categories=""
caldoc.CHAIR=Doc.TeamLeader
caldoc.Duration = 1
caldoc.ExcludefromView="D"
caldoc.From=Doc.TeamLeader
caldoc.ORGDONTDOUBLEBOOK="1"
caldoc.ORGTABLE="C0"
Call caldoc.APPENDITEMVALUE("$PublicAccess","1")
Call caldoc.AppendItemValue("$BusyName",s.username)
Call calDoc.AppendItemValue("$BusyPriority","1")
’ ----- Start of StartDateTime and TimeRange work -----
sDate.lslocaltime = doc.StartDateTime(0)
Set follupdate=New NotesDateTime(sDate.localtime)
Set tr=s.CreateDateRange()
Set tr.StartDateTime = sDate
eDate.lslocaltime = doc.EndDateTime(0)
Set tr.EndDateTime = eDate
Set caldoc.CalendarDateTime=follupdate
Set caldoc.ReminderTime=follupdate
Set caldoc.StartDate=follupdate
Set caldoc.StartDateTime=follupdate
Set caldoc.TimeRange=tr
’ ----- End of StartDateTime and TimeRange work -----
Team = Doc.TeamName(0)
Dim sDateTime As String
sDateTime = sDate.DateOnly & ", at [" & sDate.TimeOnly & "-" & eDate.TimeOnly & "] "
Set calDoc.EndDateTime = eDate
Subj = "Meeting Agenda for " & Team & " on "& sDateTime
If(Doc.MeetLocation(0) <> "") Then
Subj = Subj & " in " + Doc.MeetLocation(0)
End If
caldoc.Subject=Subj & "."
caldoc.AppointmentType="0"
Call caldoc.APPENDITEMVALUE("_ViewIcon",160)
Call caldoc.APPENDITEMVALUE("$NoPurge",eDate)
Set rtitem = New NotesRichTextItem( caldoc, "Body" )
Call rtitem.AppendText( NameImplode(Doc.CalledBy,", ") & " has called a meeting for the " & Team & " team, on: ")
Call rtitem.AppendText(sDateTime)
If(Doc.MeetLocation(0) <> "") Then
Call rtitem.AppendText( " in " + Doc.MeetLocation(0) )
End If
Call rtitem.AppendText(".")
message = "The meeting has been added to your calendar."
' Alarm information
Call calDoc.AppendItemValue("$Alarm",1)
Call calDoc.AppendItemValue("$AlarmDescription",Subj & ".")
Call calDoc.AppendItemValue("$AlarmOffset",-DBProfile.AlarmMinutes(0))
Call rtitem.AddNewLine(2)
Call rtitem.AppendText ("You can learn more by double clicking on the following Lotus Notes doclink ==> ")
Call rtitem.Appenddoclink(doc, Doc.Team(0) & " team.")
Call rtitem.AddNewLine(1)
Call caldoc.ComputeWithForm(False, False)
Call caldoc.save(True,False,False)
Msgbox(message)
End If