Domino 9 und frühere Versionen > ND6: Entwicklung
Bestimmte Dokumente per Agent löschen
DAU-in:
vielleicht stehe ich auf dem Schlauch, weil mir im Flieger soeben zweieinhalb Stunden das Hirn gedörrt wurde:
Do Until Doc Is Nothing
strUnique = Doc.Unique(0)
'Lösch jetzt alle dazugehörigen Dokumente und Antworten in der Datenbank VEntwuerfe
Set DocE = ViewE.GetDocumentByKey(strUnique)
Do While Not (DocE Is Nothing)
If DocE.Unique(0) = strUnique Then
Call DocE.Remove(True)
Doc.txtAktion = "gelöscht"
Call doc.Save(True, False)
End If
Set DocE = ViewE.GetNextDocument(DocE)
Loop
Set Doc = View.GetNextDocument(Doc)
Loop
du entfernst das Dokument, und danach willst du auf das nächste zugreifen?
mach dir noch ein docNext,
und dann
set docNext = ViewE.GetNextDocument(DocE)
docE.remove
set docE = docNext
Oder irgendwie so ...
Wiesel:
Ah, verstehe das Problem.
Ich hab das jetzt mal versucht in eine Collection zu bringen:
Sub Initialize
Dim S As New NotesSession
Dim DB As NotesDatabase
Dim Doc As NotesDocument
Dim Col As NotesDocumentCollection
Dim View As NotesView
Dim strEntwurfDB As String
Dim strEntwurfPfad As String
Dim strUnique As String
Set DB = S.CurrentDatabase
Set Doc = DB.GetProfileDocument("(DBProfil)")
'Profil Dokument auslesen
strEntwurfDB = Doc.dbServer(0)
strEntwurfPfad = Doc.dbPfad(0)
Dim VEntwuerfe As NotesDatabase
Dim DocE As NotesDocument
Dim ViewE As NotesView
Set VEntwuerfe = S.GetDatabase(strEntwurfDB,strEntwurfPfad)
Set ViewE = VEntwuerfe.GetView("(LoeschungEntwuerfeE)")
Set View = DB.GetView("(LoeschungEntwuerfe)")
Set Doc= View.GetFirstDocument
Do Until Doc Is Nothing
strUnique = Doc.Unique(0)
Set Col = View.GetAllDocumentsByKey(strUnique)
If Not Col Is Nothing Then
If Col.Count <> 0 Then
Call Col.RemoveAll(True)
End If
Doc.txtAktion = "gelöscht"
Call doc.Save(True, False)
Set DocE = Col.GetNextDocument(Doc)
End If
Loop
Call view.Refresh
End Sub
Allerdings bekomme ich in der Zeile
Doc.txtAktion = "gelöscht"
die Fehlermeldung
Object variable not set.
Das Dokument im Archiv hat den Flag bekommen, aber in der EntwurfsDB ist es nicht gelöscht worden...
DAU-in:
Set DocE = Col.GetNextDocument(Doc) ???
Da wirfst du doch die Dokumente beider Datenbanken durcheinander? :-:
tks:
call doc.ReplaceItemValue("txtAktion","gelöscht")
Und das was DAU-in geschrieben hat....
Driri:
Das Script oben ist von Wiesel nachträglich geändert worden, darum sind jetzt einige Kommentare evtl. verwirrend.
Die Zeile Set DocE = Col.GetNextDocument(Doc) kannst Du dir bei Verwendung der Collection und RemoveAll sparen.
Navigation
[0] Themen-Index
[#] Nächste Seite
[*] Vorherige Sete
Zur normalen Ansicht wechseln