Domino 9 und frühere Versionen > Entwicklung

Tochterdok löschen wenn Parent gelöscht wurde

(1/2) > >>

MrMagoo:
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

Axel:
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

MrMagoo:
@Axel: funktioniert leider nicht. Der Agent geht in die zweite If Schleife nicht rein.  :(

Axel:
Hi,

... auch wenn das entsprechende Elterndokument nicht mehr da ist ?

Was sagt den der Debugger zu dem Wert von parentdoc ?


Axel

MrMagoo:
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

Navigation

[0] Themen-Index

[#] Nächste Seite

Zur normalen Ansicht wechseln