This script finds the parent of the last document in the By Category
view of a discussion database and displays its universal ID.Sub Click(Source As Button)
Dim db As New NotesDatabase( "Byzantium", "discuss.nsf" )
Dim view As NotesView
Dim doc As NotesDocument
Dim parentDoc As NotesDocument
Set view = db.GetView( "By Category" )
If view Is Nothing Then
Messagebox "View not found"
Exit Sub
End If
Set doc = view.GetLastDocument
If doc Is Nothing Then
Messagebox "Last document not found"
Exit Sub
End If
If doc.IsResponse Then
Set parentDoc = view.GetParentDocument( doc )
If parentDoc Is Nothing Then
Messagebox "Error reading parent document"
Exit Sub
End If
Messagebox parentDoc.UniversalID, , _
"UNID of parent of last document"
Else
Messagebox doc.UniversalID, ,"UNID of last document"
End If
End Sub