Das Notes Forum
Domino 9 und frühere Versionen => Entwicklung => Thema gestartet von: MrMagoo am 23.06.03 - 14:26:01
-
Hallo Zusammen,
ich versuche gerade Tochterdokumente per Script zu ändern, wenn deren Elterndokument gelöscht wurde. Wonach kann ich da abfragen? Ich habe es versucht, wenn die ID "" ist. Er findet aber, obwohl das Dok gelöscht wurde, die ID immer noch.
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim parentUnid As String
Set db = session.CurrentDatabase
Set dc = db.unprocessedDocuments
Set doc = dc.GetFirstDocument()
While Not(doc Is Nothing)
If doc.IsResponse Then
parentUnid = doc.ParentDocumentUNID
Msgbox parentUnid
If ( parentUnid = "" ) Then
Call doc.ReplaceItemValue ( "Doc_Deleted", 1)
Call doc.Save(True, False)
End If
End If
Set doc = dc.GetNextDocument(doc)
Wend
End Sub
Danke
-
Hi,
ich denke die ID des Elterndokuments ist fest in dem Antwortdokument weingetragen und bleib auch dort, wenn das Elterndok. gelöscht wird.
Du kannst mal folgendes versuchen:
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim parentdoc As NotesDocument
Dim parentUnid As String
Set db = session.CurrentDatabase
Set dc = db.unprocessedDocuments
Set doc = dc.GetFirstDocument()
While Not(doc Is Nothing)
If doc.IsResponse Then
parentUnid = doc.ParentDocumentUNID
'Suche ob Elterndok. vorhanden
Set parentdoc = db.GetDocumentByUNID(parentUnid)
If parentdoc Is Nothing Then
Call doc.ReplaceItemValue ( "Doc_Deleted", 1)
Call doc.Save(True, False)
End If
End If
Set doc = dc.GetNextDocument(doc)
Wend
End Sub
Axel
-
@Axel: funktioniert leider nicht. Der Agent geht in die zweite If Schleife nicht rein. :(
-
Hi,
... auch wenn das entsprechende Elterndokument nicht mehr da ist ?
Was sagt den der Debugger zu dem Wert von parentdoc ?
Axel
-
Hi,
ja, ich habe zu Testzwecken das Elterndoc gelöscht und er hat das Feld im Tochterdok nicht geändert. Er geht brav bis zum
If parentdoc Is Nothing Then und dann zum End if
-
Hi,
stimmt.´
Versuch's mal so:
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim parentdoc As NotesDocument
Dim parentUnid As String
Set db = session.CurrentDatabase
Set dc = db.unprocessedDocuments
Set doc = dc.GetFirstDocument()
While Not(doc Is Nothing)
If doc.IsResponse Then
parentUnid = doc.ParentDocumentUNID
'Suche ob Elterndok. vorhanden
Set parentdoc = db.GetDocumentByUNID(parentUnid)
If parentdoc.NoteID = "" Then
Call doc.ReplaceItemValue ( "Doc_Deleted", 1)
Call doc.Save(True, False)
End If
End If
Set doc = dc.GetNextDocument(doc)
Wend
End Sub
Axel
-
Hm,
jetzt macht er es, danke :D