Script editiert nicht alle Dokumente?!

  • Hi zusammen,
    mir ist da etwas aufgefallen was ich nicht so ganz verstehe.
    Ich habe mit einem Lotus Script versucht bei Kalenderdokumente ein Feld in derMaildatenbank zu editieren. Leider können aus mir unerklärlichen Gründen nicht alle Dokumente editiert werden. Wenn ich dies via Formelsprache mache geht es ohne Probleme. Vielleicht hat einer von euch ja ne Idee wieso das so ist.


    Formelsprache:
    FIELD ExcludeFromView := "D";SELECT @All
    Script:
    Sub Click(Source As Button)
    On Error Goto Fehler
    Dim Session As New NotesSession
    Dim Db As NotesDatabase
    Dim archiv As New notesdatabase("","")
    Dim view As NotesView
    Dim success As Variant
    Dim user As String
    Dim dateTime As New NotesDateTime("")
    Dim mails As notesdocumentcollection
    Dim mail As notesdocument
    Dim lokal As New notesdatabase("","")
    Dim memo As NotesDocument
    user = session.CommonUserName
    Set db = Session.CurrentDatabase
    Set view = db.GetView("($All)")
    Set Doc = view.GetFirstDocument
    Set lokal = session.currentdatabase
    Set mails = lokal.Alldocuments
    Set mail = mails.getfirstdocument
    Set memo = New NotesDocument( db )
    intRows = 0
    While Not doc Is Nothing
    Datum = doc.StartDate(0)
    doc.Daterun = Today()
    If doc.hasitem("AppointmentType") Then
    Call doc.ReplaceItemValue ("ExcludeFromView", "D")
    If doc.AppointmentType(0)="1" Or doc.AppointmentType(0)="2" Then
    Datetime.localtime = doc.StartDate(0)
    Dim dneu As New NotesDateTime(datetime.DateOnly &" "&"23:00:00")
    Dim dneu1 As New NotesDateTime(datetime.DateOnly &" "&"01:00:00")
    Dim dneu2 As New NotesDateTime(datetime.DateOnly &" "&"23:00:00")
    Dim dneu3 As New NotesDateTime(datetime.DateOnly &" "&"01:00:00")
    Dim dneu4 As New NotesDateTime(datetime.DateOnly &" "&"01:00:00")
    Dim dneu5 As New NotesDateTime(datetime.DateOnly &" "&"23:00:00")
    Dim dneu6 As New NotesDateTime(datetime.DateOnly &" "&"01:00:00")
    Dim dneu7 As New NotesDateTime("23:00:00")
    Dim dneu8 As New NotesDateTime("01:00:00")
    Call doc.ReplaceItemValue ("AppendStartTime", dneu8)
    Call doc.ReplaceItemValue ("AppendEndTime", dneu7)
    Call doc.ReplaceItemValue ("StartDateTime", dneu1 )
    Call doc.ReplaceItemValue ("ENDDATETIME", dneu )
    Call doc.ReplaceItemValue ("Daterun", dneu4)
    Call doc.ReplaceItemValue ("StartDate", dneu3)
    Call doc.ReplaceItemValue ("EndDate", dneu2)
    Call doc.ReplaceItemValue ("StartTime", dneu6)
    Call doc.ReplaceItemValue ("EndTime", dneu5)
    Call doc.Save( True, True )
    End If
    If doc.AppointmentType(0)="0"Then
    Call doc.ReplaceItemValue ("AppointmentType", "0")
    Call doc.Save( True, True )
    End If
    If doc.AppointmentType(0)="3" Then
    Call doc.ReplaceItemValue ("AppointmentType", "3")
    Call doc.Save( True, True )
    End If
    If doc.AppointmentType(0)="4" Then
    Call doc.ReplaceItemValue ("AppointmentType", "4")
    Call doc.Save( True, True )
    End If
    End If


    intRows = intRows + 1
    Print "Updating document " & intRows
    Set Doc = view.GetNextDocument(doc)

    If Doc Is Nothing Then
    Print " Alle Kalendereinträge wurden in der Maildatenbank angepasst."
    Print " "

    memo.Form = "Memo"
    memo.SendTo = "kalender"
    memo.Subject = user & " Kalenderanpassung in der Maildatenbank abgeschlossen."
    memo.Body = "Maildatenbank OK!"
    Call memo.Send(False)

    End If
    Wend


    On Error Goto Fine
    Call archiv.Open ( "", "pst.nsf")
    Set view = archiv.GetView("($All)")
    Set Doc = view.GetFirstDocument
    intRows = 0
    While Not doc Is Nothing
    doc.Daterun = Today()
    If doc.hasitem("AppointmentType") Then
    Call doc.ReplaceItemValue ("ExcludeFromView", "D")
    If doc.AppointmentType(0)="1" Or doc.AppointmentType(0)="2" Then
    Datetime.localtime = doc.StartDate(0)
    Dim dneu0 As New NotesDateTime(datetime.DateOnly &" "&"23:00:00")
    Dim dneu10 As New NotesDateTime(datetime.DateOnly &" "&"01:00:00")
    Dim dneu20 As New NotesDateTime(datetime.DateOnly &" "&"23:00:00")
    Dim dneu30 As New NotesDateTime(datetime.DateOnly &" "&"01:00:00")
    Dim dneu40 As New NotesDateTime(datetime.DateOnly &" "&"01:00:00")
    Dim dneu50 As New NotesDateTime(datetime.DateOnly &" "&"23:00:00")
    Dim dneu60 As New NotesDateTime(datetime.DateOnly &" "&"01:00:00")
    Dim dneu70 As New NotesDateTime("23:00:00")
    Dim dneu80 As New NotesDateTime("01:00:00")
    Call doc.ReplaceItemValue ("AppendStartTime", dneu80)
    Call doc.ReplaceItemValue ("AppendEndTime", dneu70)
    Call doc.ReplaceItemValue ("StartDateTime", dneu10 )
    Call doc.ReplaceItemValue ("ENDDATETIME", dneu0 )
    Call doc.ReplaceItemValue ("Daterun", dneu40)
    Call doc.ReplaceItemValue ("StartDate", dneu30)
    Call doc.ReplaceItemValue ("EndDate", dneu20)
    Call doc.ReplaceItemValue ("StartTime", dneu60)
    Call doc.ReplaceItemValue ("EndTime", dneu50)
    Call doc.Save( True, True )
    End If
    If doc.AppointmentType(0)="0"Then
    Call doc.ReplaceItemValue ("AppointmentType", "0")
    Call doc.Save( True, True )
    End If
    If doc.AppointmentType(0)="3" Then
    Call doc.ReplaceItemValue ("AppointmentType", "3")
    Call doc.Save( True, True )
    End If
    If doc.AppointmentType(0)="4" Then
    Call doc.ReplaceItemValue ("AppointmentType", "4")
    Call doc.Save( True, True )
    End If
    End If

    intRows = intRows + 1
    Print "Updating document " & intRows
    Set Doc = view.GetNextDocument(doc)
    If Doc Is Nothing Then
    Print " Alle Kalendereinträge wurden in der Archivdatenbank angepasst"
    Print " "
    memo.Form = "Memo"
    memo.SendTo = "kalender"
    memo.Subject = user & " Kalenderanpassung in der Archivdatenbank abgeschlossen."
    memo.Body = "Archivdatenbank OK!"
    Call memo.Send(False)

    Goto ende

    ' Exit Do
    End If
    Wend
    '--weiter--

    Exit Sub
    fine:
    memo.Form = "Memo"
    memo.SendTo = "kalender"
    memo.Subject = user & " Fehler bei der Kalenderanpassung in der Archivdatenbank."
    memo.Body = "Archivdatenbank nicht umgestellt!"
    Call memo.Send(False)
    Msgbox "Die Aktualisierung Ihres Kalenders wurde erfolgreich abgeschlossen. Allerdings konnte Ihre Archivdatenbank nicht gefunden werden. Eine Infomation über dieses Ereignis wurde an die Administration weitergegeben. - Bitte betätigen Sie jetzt die Schaltfläsche Termine",79,"Infomation"
    On Error Goto Finish1
    Goto ende1
    Exit Sub


    Fehler:
    memo.Form = "Memo"
    memo.SendTo = "kalender"
    memo.Subject = user & " Fehler bei der Kalenderanpassung! Umstellung ist nicht erfolgt."
    memo.Body = "Archivdatenbank & Maildatenbank wurden nicht umgestellt"
    Call memo.Send(False)
    Msgbox "Die Aktualisierung Ihres Kalenders wurde nicht erfolgreich abgeschlossen. Eine Infomation über dieses Ereignis wurde an die Administration weitergegeben.", 79, "Iformation"
    Goto ende1
    Exit Sub

    ende:
    Msgbox "Die Aktualisierung Ihres Kalenders wurde erfolgreich abgeschlossen. Bitte betätigen Sie als nächstes die Schaltfläche Termine ",79,"Erfolgreich"
    Goto ende1
    Exit Sub
    ende1:
    Exit Sub
    Finish1:
    End Sub


    Gruß und THX
    Heinz

  • Eigentlich ist die Lösung ziemlich einfach:


    Die Ansicht ($All) enthält nicht alle Dokumente, also werden die bei deinem Script natürlich nicht bearbeitet.
    Verwende doch einfach die Eigenschaft AllDocuments der NotesDatabase Class.
    Die liefert dir die gleichen Dokumente wie die Formelauswahl SELECT @All