GetNamedDocument (NotesDatabase - LotusScript)

Returns a named document.

Note: This method is new in R12.0.1

Defined in

NotesDatabase

Syntax

.GetNamedDocument( String Name, Optional String username )As NotesDocument

Parameters

name username

String. Specifies the name of a named document. Can be followed by an optional user name to associate a user with the named document.

Usage

Returns a named document, a type of document that has a name rather than a NoteID and does not appear in the Notes client or in any view. A named document is designed for programmatic access and is a functional replacement for profile documents used previously.

If a named document of the specified name is not found, it is created. The Document property IsNewNote returns True if the document is created or False if it existed previously.

An optional username qualifier can be added to be used as a data store for that user.

A named document can have both asterisks (*) and period (.) in their names.

Example

Dim s As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim dc As NotesDocumentCollection
Dim outputstr As String
	
Set db = s.CurrentDatabase
Set doc = db.GetNamedDocument("MyNamedDoc1")	
Msgbox  "Name: " + doc.NameOfDoc  + "  UserName: "  + doc.UserNameOfDoc +  "  new? " + Cstr(doc.isNewNote)

Set doc = db.GetNamedDocument("MyNamedDoc1","John Doe" )	'
Msgbox  "Name: " + doc.NameOfDoc  + "  UserName: "  + doc.UserNameOfDoc +  "  new? " + Cstr(doc.isNewNote)

Set doc = db.GetNamedDocument("MyNamedDoc2")	
Msgbox  "Name: " + doc.NameOfDoc  + "  UserName: "  + doc.UserNameOfDoc +  "  new? " + Cstr(doc.isNewNote)

Set doc = db.GetNamedDocument("MyNamedDoc2","John Doe" )	'
Msgbox  "Name: " + doc.NameOfDoc  + "  UserName: "  + doc.UserNameOfDoc +  "  new? " + Cstr(doc.isNewNote)

Set dc = db.GetNamedDocCollection()

outputstr = "Collection: "  + Chr$(13)
Set doc = dc.GetFirstDocument

While Not doc Is Nothing
	outputstr = outputstr +"name: " + doc.NameOfDoc + "   UserName: " + doc.UserNameOfDoc + "    new?: " + Cstr(doc.isnewnote) + Chr$(13)
	Set doc = dc.getnextdocument(doc)
Wend

Msgbox outputstr

outputstr = "Qualified Collection: "  + Chr$(13)

Set dc = db.GetNamedDocCollection("MyNamedDoc1")

Set doc = dc.GetFirstDocument

While Not doc Is Nothing
	outputstr = outputstr +"name: " + doc.NameOfDoc + "   UserName: " + doc.UserNameOfDoc + "    new?: " + Cstr(doc.isnewnote) + Chr$(13)
	Set doc = dc.getnextdocument(doc)
Wend

Msgbox outputstr