Examples: ParentDatabase property
- This script prints the title of the NotesDatabase object from
which a document was retrieved (db), and the title of the NotesDatabase
object returned by the ParentDatabase property (parentDb). The titles
are the same, because db and parentDb represent the same database,
SOMEDOCS.NSF.
Dim db As New NotesDatabase( "", "somedocs.nsf" ) Dim parentDb As NotesDatabase Dim collection As NotesDocumentCollection Dim doc As NotesDocument Set collection = db.AllDocuments Set doc = collection.GetFirstDocument Set parentDb = doc.ParentDatabase Messagebox( db.Title ) Messagebox( parentDb.Title )
- This script shows a function that takes a document and returns
its parent document (or Nothing if the document has no parent). The
function uses the ParentDatabase property to get db, a NotesDatabase
object representing the database that doc is in. Once the script
has db, it can call GetDocumentByUNID to find doc's
parent.
Function GetParentDocument( doc As NotesDocument ) Dim db As NotesDatabase Dim parentDoc As NotesDocument Set db = doc.ParentDatabase If doc.IsResponse Then Set parentDoc = db.GetDocumentByUNID _ ( doc.ParentDocumentUNID ) End If Set GetParentDocument = parentDoc End Function
This function can be called from any script. For example:
dim myQuestion as NotesDocument dim yourAnswer as NotesDocument '...set value of yourAnswer... set myQuestion = GetParentDocument( yourAnswer )