I am trying yo create a calendar item in a user’s mailfile. A added the script by which this is performed. It seems to work. An itme is created, with today’s date/time. The variable plantijd is used the set the enddate of the meeting.These values appear correctly in the calendar.
But when I want to change the endtime os the starttime, the duration defaults to 1 hour (which is set in the preferences-document in the mailfile). How can I move the duration over the time with the original duration held?
Sub Click(Source As Button)
Dim w As New NotesUIWorkspace
Dim s As New NotesSession
Dim calndruidoc As NotesUIDocument 'document in calendar (FE)
Dim calndrdoc As NotesDocument 'document in calendar (BE)
Dim dluidoc As NotesUIDocument 'this document (daglijst) (FE)
Dim dldoc As NotesDocument 'this document (daglijst( (BE)
Dim tdoc As NotesDocument 'document task (BE)
Dim vdoc As NotesDocument 'document verrichting (BE)
Dim tview As NotesView 'view tasks by ID
Dim vview As NotesView 'view verrichtingen
Dim maildb As NotesDatabase 'maildatabase
Dim curdb As NotesDatabase 'current database, needed to obtian current servername
Dim reg As New NotesRegistration 'var for obtaining properties certain user
Dim mailserver As String, mailfile As String, maildomain As String 'needed for var REG
Dim mailsystem As Integer 'needed for var REG
Dim username As String 'users whose mailfile is opened
Dim picklistresult As Variant
Dim subject As String, apptype As String
Dim calstartdatetime As New NotesDateTime("")
Dim calenddatetime As New NotesDateTime("")
Set curdb=s.CurrentDatabase 'current database
Dim tabeldb As New NotesDatabase(curdb.Server,"verzuimvisietables.nsf")
Dim tid As String 'id task
Dim tvid As String 'id gekoppelde verrichting
Dim plantijd As Integer
Set dluidoc=w.CurrentDocument
Set dldoc=dluidoc.Document
picklistresult= w.PickListStrings( PICKLIST_NAMES ) 'choose name from adresbook
username=picklistresult(0)
reg.RegistrationServer=curdb.Server
Call reg.GetUserInfo(username,mailserver$,mailfile$,maildomain$,mailsystem%)
Set maildb=New NotesDatabase(curdb.Server,mailfile) 'the user's mailfile
subject=dldoc.dl_naam(0)+"; "+dldoc.dl_w_naam(0)
REM ophalen gegevens uit taakdocument
Set tview=tabeldb.GetView("overzichten") 'view tasks
Set vview=tabeldb.GetView("verrichtingen") 'view verrichtingen
tid=dluidoc.FieldGetText("dl_t_id")
Set tdoc=tview.GetDocumentByKey(tid)
tvid=tdoc.t_v_id(0) 'id van gekoppelde verrichting in taak
Set vdoc=vview.GetDocumentByKey(tvid)
plantijd=vdoc.v_plantijd(0)
REM Calculate date-time-values
Call calstartdatetime.SetNow
Call calenddatetime.SetNow
Call calenddatetime.AdjustMinute(plantijd,True)
REM Next lines of code set the type of Appointment
apptype=dluidoc.FieldGetText("dl_app_type") 'type-number is saved in document dluidoc
Call s.SetEnvironmentVar("CSDocType",apptype)
Set calndruidoc=w.ComposeDocument(curdb.Server,mailfile,"Appointment")
Set calndrdoc=calndruidoc.Document
Select Case apptype
Case "3":
With calndrdoc
.StartDateTime=calstartdatetime.LocalTime 'startdate/time in appointment
.StartDate=calstartdatetime.LocalTime 'startdate in appointment
.EndDateTime=calenddatetime.LocalTime 'enddate/time in appointment
.EndDate=calstartdatetime.LocalTime 'enddate in appointment; same as startdate
.StartTime=calstartdatetime.LocalTime 'starttime in appointment
.EndTime=calenddatetime.LocalTime 'endtime in appointment
.Subject=subject 'subject in appointment
End With
Case Else
End Select
Call calndrdoc.Save(True,False)
Call calndruidoc.Reload
Call calndruidoc.Refresh
End Sub