Laut KBASE ist ein "ghost document" ein gelöschtes Hauptdokument, zu dem es eine Antwort gibt.
Hier der Artikel:
Problem
The ParentDocumentUNID property (of the NotesDocument class), when used in conjunction with the GetDocumentByUNID method (of the NotesDatabase class), allows you to get a handle to a response document's parent document.
If the parent document of the response document (also known as a child document) has been deleted, the response document is considered an orphan. The deleted parent document is considered a ghost.
When you use the GetDocumentByUNID method to attempt to get a handle to the parent of an orphan, an error usually occurs. The actual text of the error, however, varies depending on the version of Notes. Furthermore, certain Notes releases do not generate an error.
Below is a sample script. When you run this script in various Notes 4.x releases, the results are different.
Sample Script:
Sub Initialize
Dim session As New notessession
Dim cdoc As notesdocument
Dim pdoc As notesdocument
Dim db As notesdatabase
Dim view As notesview
Set db=session.currentdatabase
Set view=db.getview("Parent and Child")
Set cdoc=view.getfirstdocument
While Not (cdoc Is Nothing)
If cdoc.isresponse Then
Set pdoc=db.getdocumentbyUNID(cdoc.parentdocumentUNID)
' Attempting to access the parent of an orphan, above, will cause an error in most Notes releases
End If
Set cdoc=view.getnextdocument(cdoc)
Wend
End Sub
Below is a breakdown of how the different Notes 4.x releases react when you attempt to get a handle to the parent of an orphan document:
Notes 4.1x:
A handle to the document is returned but attempting to access any of the document's properties results in the following error:
"Notes error: Document has been deleted"
The error number associated with this message is 4000.
Notes 4.5x (except Notes 4.5.4a):
The following error results:
"Notes error: Document has been deleted (<ParentDocumentUNID>)"
The error number associated with this message is 4005.
Notes 4.6, 4.6a, 4.6.2x & 4.6.3x:
The following error results:
"Invalid universal ID"
The error number associated with this message is 4091.
Notes 4.5.4a, Notes 4.6.1x, Notes 4.6.4x and higher (including Notes 5.0):
No error occurs. You get a handle to the ghost (deleted parent) document. You can perform a check to determine whether the Size property of the returned document handle is greater than zero to verify whether the parent document has been accessed.
It is actually this behavior that is most appropriate. Although the parent document has been deleted, it still has children, and it is most appropriate for Notes to keep a shell of the parent around as a placeholder (to help keep track of the children).
Conclusion:
If you need to code error handling to deal with the various possible outcomes, you must check for errors 4005, 4091 (for releases 4.5x, 4.6, 4.6a, and 4.6.2x) and error 4000 (which occurs when you attempt to access a document property in 4.1x). You must also check if the Size property equals zero (to check for 4.5.4a, 4.6.1x, 4.6.3 and up). Note: Error codes can change from release to release and thus will not necessarily be the same going from one release to another.
The code below demonstrates provides one way this can be done. An 'On Error' statement is used to route control of the code if an error occurs. The error handling section checks whether the error is one of those expected, and resumes the code such that it gets the next document. If an error is not encountered, the code verifies that the document handle is not for a 'ghost' document (by checking the size).
Sample Script:
Sub Initialize
Dim session As New notessession
Dim cdoc As notesdocument
Dim pdoc As notesdocument
Dim db As notesdatabase
Dim view As notesview
Set db=session.currentdatabase
Set view=db.getview("Parent and Child")
On Error Goto errhandle
Set doc=view.getfirstdocument
While Not (cdoc Is Nothing)
If cdoc.isresponse Then
Set pdoc=db.getdocumentbyUNID(cdoc.parentdocumentUNID)
If pdoc.size = 0 Then
' Found orphan in 4.6.1x, 4.5.4a. Got handle but size=0.
End If
End If
GetNextDoc:
Set cdoc=view.getnextdocument(cdoc)
Wend
Exit Sub
ErrHandle:
If Err=4091 Or Err=4005 Or Err=4000 Then
' Found orphan in 4.1x, 4.5x, 4.6x or 4.6.2x
Resume GetNextDoc
End If
Messagebox "Error # " & Cstr(Err) & ": " & Error$
Exit Sub
End Sub
Supporting Information:
With all Notes Releases: When you have a handle to a parent document and mistakenly attempt to use ParentDocumentUNID with the GetDocumentByUNID method, the following error occurs:
"Invalid universal ID"
The error code associated with this message is 4091.
It is important to note that this is the same error message you receive when you attempt to access the parent of an orphan in Notes releases 4.6, 4.6a, and 4.6.2x.
One way to avoid trying to access the parent of a document that is actually a parent itself is to use the IsResponse property (of the NotesDocument class). This methodology is utilized in the Conclusion section of the technote.
Related Documents:
How to Find Orphan Documents
Document #: 113861
Andreas