Das Notes Forum

Domino 9 und frühere Versionen => ND6: Entwicklung => Thema gestartet von: Thorsten Kalweit am 18.11.08 - 11:46:48

Titel: Kalendereintrag mit Skript
Beitrag von: Thorsten Kalweit am 18.11.08 - 11:46:48
Hallo zusammen,

gibt es die Möglichkeit einen Kalendereintrag (Termin) für jemand anderes zu erstellen?

Das Problem:
In einer Datenbank werden Termine erstellt und mit einer Schaltfläche werden diese in die Kalender übertragen. Die Datenbank dient zur Hilfestellung der Raumauswahl.
Es kommt allerdings auch häufig vor, dass Personen auch für andere einen Termin eintragen.

Lässt sich das Problem mit Skript umgehen?
Ich hätte mir ein Auswahlfeld vorgestellt: "Eintrag für: ".

Vielen Dank für die Hilfestellung im Voraus.

Viele Grüße
Thorsten

Hier ersteinmal, das Skript, was jetzt schon - bis auf das Problem - erfolgreich im Einsatz ist.
Sub Click(Source As Button)
   Dim session As New NotesSession   
   Dim db As New NotesDatabase ("","")
   Dim UiWs As New NotesUIWorkspace
   Dim uidoc As NotesUIDocument
   Dim doc As notesdocument
   Dim startdatum As String
   Dim startzeit As String
   Dim enddatum As String
   Dim endzeit As String
   Dim thema As String
   Dim personen As String
   Dim optpersonen As String
   Dim infopersonen As String
   Dim raum As String
   
   Dim userName As New notesname(session.username)
   Dim dbfilename As String
   Dim dbserver As String
   Dim value As Integer
   
   Set uidoc = UiWs.CurrentDocument
   Set doc = uidoc.Document
   
   startdatum = uidoc.FieldGetText("StartDate")
   startzeit = uidoc.FieldGetText("StartTime")
   enddatum = uidoc.FieldGetText("EndDate")
   endzeit = uidoc.FieldGetText("EndTime")
   thema = uidoc.FieldGetText("thema")
   raum = uidoc.FieldGetText("auswahlraum")
   personen = uidoc.FieldGetText("tmpPersonen_1")
   optpersonen = uidoc.FieldGetText("optpersonen")
   infopersonen = uidoc.FieldGetText("infopersonen")
   
   Call db.OpenMail   
   dbfilename=db.filepath   
   dbserver = db.server
'*****************Do this chunk of code for each holiday in the year**************************     
   Set uidoc = UiWs.ComposeDocument (dbserver,dbfilename,"Appointment")
   Call uidoc.FieldSetText("AppointmentType","3")
   Call uidoc.Refresh
   Call uidoc.FieldSetText("Subject", thema)
      'Datumswerte
   Call uidoc.FieldSetText("StartDate",startdatum)
   Call uidoc.FieldSetText("EndDate",enddatum)
   Call uidoc.FieldSetText("StartTime",startzeit)
   Call uidoc.FieldSetText("EndTime",endzeit)
   Call uidoc.FieldSetText("Location",raum)
      'Raum
   Call uidoc.FieldSetText("RoomToReserve",raum)
   'Personen
   Call uidoc.FieldSetText("EnterSendTo",personen)
   Call uidoc.FieldSetText("EnterCopyTo",optpersonen)
   Call uidoc.FieldSetText("EnterBlindCopyTo",infopersonen)
   
   
   Call uidoc.Refresh
      'Call uidoc.Save()
      'Call uidoc.Close()
'****************************************************************************************************   
End Sub
Titel: Re: Kalendereintrag mit Skript
Beitrag von: eknori am 18.11.08 - 11:50:56
Das hier (http://atnotes.de/index.php?topic=41883.msg268602#msg268602 (http://atnotes.de/index.php?topic=41883.msg268602#msg268602)) könnte hilfreich sein.
Titel: Re: Kalendereintrag mit Skript
Beitrag von: Thorsten Kalweit am 20.11.08 - 11:58:16
Hi eknori,

ich möchte das Skript gerne ausführen, aber leider meckert der Debugger immer, dass die Klasse an der Stelle
Dim notesdir As NotesDirectory
Set notesdir  = s.getDirectory(DD_SERVER)


nicht gefunden wurde.


Das hat sich schon erledigt ;-)

Ich werde erstmal etwas basteln und melde mich später wieder. Trtzdem danke  :)

Ich muss gestehen, dass ich kein Scriptexperte bin  ;)

Viele Grüße
Thorsten
Titel: Re: Kalendereintrag mit Skript
Beitrag von: Thorsten Kalweit am 20.11.08 - 13:46:26
Eine Frage habe ich doch noch:

Wo bringe ich in eknori's Skript den RoomToReserve unter?

Viele Grüße
Thorsten
Titel: Re: Kalendereintrag mit Skript
Beitrag von: klaussal am 20.11.08 - 14:06:28
Steht doch schon drin...

Code
 'Raum
   Call uidoc.FieldSetText("RoomToReserve",raum)
Titel: Re: Kalendereintrag mit Skript
Beitrag von: koehlerbv am 20.11.08 - 14:09:45
Ob man dort aber etwas hineinschreibt oder in China ein Sack Reis umfällt, ist ziemlich das gleiche: Eine Reservierung findet damit nicht statt, das ist eine ganz andere Baustelle!

Bernhard
Titel: Re: Kalendereintrag mit Skript
Beitrag von: Thorsten Kalweit am 20.11.08 - 14:19:09
Es geht um dieses Skript :

http://atnotes.de/index.php?topic=41883.msg268602#msg268602

Titel: Re: Kalendereintrag mit Skript
Beitrag von: Thorsten Kalweit am 20.11.08 - 14:25:27
Jetzt klappt es auch mit dem Nachbarn.

Hier die komplette Lösung:

Const APP_FORM = "Appointment"
Const DD_SERVER = "Mail01"
Const SEPERATOR = "!!"
Class CEntry
   
   Public Sub new()
   End Sub
   
   Private startdttm As NotesDateTime
   Private enddttm As NotesDateTime   
   Private moddttm As NotesDateTime
   Public Property Set StartDT As NotesdateTime
      Set startdttm = StartDT
   End Property
   Public Property Set EndDT As NotesdateTime
      Set enddttm = EndDT
   End Property
   
   Private strLocation As String
   Public Property Set Location As String   
      Me.strLocation = Location
   End Property   
   
   Private varCategories As Variant
   Public Property Set Categories As String   
      Me.varCategories = Split(Categories,";")
   End Property
   
   Private strType As String
   Public Property Set AppType As String   
      Me.strType = AppType
   End Property
   
   Private varRoom As String
   Public Property Set Room As String   
      Me.varRoom = Room
   End Property
   
   
   Public Property Get AppType As String   
      Select Case Ucase (Me.StrType)
      Case "APPOINTMENT", "TERMIN"
         AppType = "0"
      Case "ANNIVERSARY", "JAHRESTAG"
         AppType = "1"
      Case "EVENT", "GANZTAEGIGE VERANSTALTUNG"
         AppType = "2"
      Case "MEETING", "BESPRECHUNG"
         AppType = "3"
      Case "REMINDER", "ERINNERUNG"
         AppType = "4"
      Case Else
         AppType = "0"
      End Select
   End Property
   
   Private strsubject As String
   Public Property Get subject As String
      subject = Me.strsubject
   End Property
   Public Property Set subject As String
      Me.strsubject = subject
   End Property   
   
   Private struser As String
   Public Property Get user As String
      user = Me.struser
   End Property
   Public Property Set user As String
      Me.struser = user
   End Property
   
   
   Public Property Get MailFile As String
      Dim s As New NotesSession
      
      If Me.struser = "" Then
         MailFIle = ""
      Else ' Notes Version is < 8.x
         
         If s.NotesBuildVersion < 307 Then
            Dim db As New NotesDatabase ( DD_SERVER, "names.nsf" )
            Dim v As NotesView
            Dim doc As NotesDocument
            If db.IsOpen() Then
               Set v = db.GetView("($Users)")
               If Not ( v Is Nothing ) Then
                  Set doc = v.GetDocumentByKey (Me.user)
                  If Not ( doc Is Nothing ) Then
                     MailFIle = doc.MailServer(0) & SEPERATOR & doc.MailFile(0)
                  Else
                     Goto ERR_USER_NOT_FOUND
                  End If
               Else
                  Goto ERR_USER_NOT_FOUND
               End If
            Else
               Goto ERR_USER_NOT_FOUND
            End If
            
         'Else ' we are running at least Notes Version 8
         '   On Error 4731 Goto ERR_USER_NOT_FOUND
         '   Dim notesdir As NotesDbDirectory
         '   Set notesdir  = s.getDbDirectory(DD_SERVER)
         '   Dim homeserver As Variant
         '   homeserver =  notesdir.GetMailInfo(Me.struser, False, False)
         '   mailfile = Cstr(homeserver(0)) & SEPERATOR & Cstr(homeserver(3))   
         End If         
EXIT_PROPERTY:
         Exit Property
ERR_USER_NOT_FOUND:
         mailfile = ""
         Resume EXIT_PROPERTY
      End If
      
   End Property
   
   Public Function CreateSingleEntry As Integer
      CreateSingleEntry = 0 ' no error
      
      If Trim(Me.strSubject) = "" Then
         CreateSingleEntry = 3 ' Subject missing
         Exit Function
      End If
      
      If Me.startdttm.TimeDifference (Me.enddttm) > 0 Then
         CreateSingleEntry = 4 ' EndDT before StartDT
         Exit Function
      End If
      
      If Me.MailFile = "" Then
         CreateSingleEntry = 1 'No MailFile or User not found
         Exit Function
      End If
      
      Dim db As New NotesDatabase ( _
      Strtoken (Me.Mailfile,SEPERATOR,1), Strtoken (Me.Mailfile,SEPERATOR,2))
      
      If db.IsOpen () Then
         Dim session As New NotesSession
         Dim nam As NotesName
         Dim cEntry As New NotesDocument (db)
         Dim rtitem As Variant
         Dim itemIcon As NotesItem
         Dim item As NotesItem
         Dim ret As Variant
         
         Set nam = session.CreateName(Me.struser)      
         
         '----------- Set User and Description ----------------
         cEntry.Form = APP_FORM
         cEntry.~$Programmatically = "1"
         'cEntry.tmpOwnerHW = "0"
         Set item = New NotesItem(cEntry, "From", nam.canonical)
         item.IsAuthors = True
         Set item = New NotesItem(cEntry, "Principal", nam.canonical)
         'Set item = New NotesItem(cEntry, "Chair", nam.canonical)
         Set item = New NotesItem(cEntry, "$BusyName", nam.canonical)
         item.IsNames = True
         Set item = New NotesItem(cEntry, "RoomTReserve", nam.canonical)
         item.IsNames = True
         
         cEntry.AppointmentType = Me.AppType
         Select Case Me.AppType
         Case 0
            Set itemIcon = New NotesItem(cEntry, "_ViewIcon", 160)
         Case 1
            Set itemIcon = New NotesItem(cEntry, "_ViewIcon", 63)   
         Case 2
            Set itemIcon = New NotesItem(cEntry, "_ViewIcon", 168)
         Case 3
            Set itemIcon = New NotesItem(cEntry, "_ViewIcon", 9)
         Case 4
            Set itemIcon = New NotesItem(cEntry, "_ViewIcon", 158)
         End Select
         itemIcon.IsSummary = True
         
         cEntry.~$BusyPriority = "1"
         cEntry.Subject = Me.subject
         
         '----------- Set Date and Times ----------------
         cEntry.StartDateTime = Me.startdttm.LSLocalTime
         cEntry.StartDate = Me.startdttm.LSLocalTime
         cEntry.StartTime = Me.startdttm.LSLocalTime
         cEntry.EndDateTime = Me.enddttm.LSLocalTime
         cEntry.EndDate = Me.enddttm.LSLocalTime
         cEntry.EndTime = Me.enddttm.LSLocalTime
         cEntry.calendarDateTime = Me.startdttm.LSLocalTime
         
         '----------- Set Other Fields ----------------
         cEntry.~$NoPurge = Me.enddttm.LSLocalTime
         cEntry.~$PublicAccess = "1"
         cEntry.MailOptions=""
         cEntry.tmpWhichList = ""
         
         Set item = New NotesItem(cEntry, "ExcludeFromView", "D")
         Call item.AppendToTextList ("S")
         cEntry.OrgTable = "C0"
         cEntry.Location = Me.strLocation
         cEntry.RoomToReserve = Me.varRoom
         Set item = New NotesItem(cEntry, "Categories", varCategories)            
         'cEntry.Categories = "Test"
         cEntry.Logo = "stdNotesLtr0"
         cEntry.OrgState = "x"
         cEntry.Repeats = ""
         cEntry.Resources = ""
         cEntry.SaveOptions = ""
         cEntry.SequenceNum = "1"
         cEntry.APPTUNID = cEntry.UniversalID
         '//Call cEntry.ComputeWithForm (False,True)
         Call cEntry.save(False, True)
         
      Else
         CreateSingleEntry = 2 'MalFile cannot be opened
      End If
   End Function
   
End Class


Und die Schaltfläche:
Sub Click(Source As Button)
   Dim session As New NotesSession
   Dim UiWs As New NotesUIWorkspace
   Dim uidoc As NotesUIDocument
   Dim user As String
   Dim CEntry As New CEntry()
   
   Set uidoc = UiWs.CurrentDocument
   Set doc = uidoc.Document
   
   CEntry.AppType = "BESPRECHUNG"
   CEntry.User = uidoc.FieldGetText("CPerson")
   CEntry.Subject = uidoc.FieldGetText("thema")
   CEntry.Location = uidoc.FieldGetText("auswahlraum")
   CEntry.Room = uidoc.FieldGetText("auswahlraum")
   CEntry.Categories = uidoc.FieldGetText("thema")
   Set CEntry.StartDT = New NotesDateTime("20.11.2008 14:00:00")
   Set CEntry.EndDT = New NotesDateTime("20.11.2008 15:00:00")
   
   Msgbox CEntry.CreateSingleEntry
   
End Sub


Vielen Dank an alle