NotesDocument (LotusScript®)

Represents a document in a database.

Containment

Contained by: NotesDatabase, NotesDocumentCollection, NotesNewsletter, NotesUIDocument, NotesView, NotesViewEntry

Contains: NotesDateRange, NotesDateTime, NotesEmbeddedObject, NotesItem, NotesMIMEEntity, NotesRichTextItem

Properties

Authors

ColumnValues

Created

EmbeddedObjects

EncryptionKeys

EncryptOnSend

FolderReferences

FTSearchScore

HasEmbedded

HttpURL

IsDeleted

IsEncrypted

IsNewNote

IsProfile

IsResponse

IsSigned

IsUIDocOpen

IsValid

Items

Key

LastAccessed

LastModified

LockHolders

NameOfProfile

NoteID

NotesURL

ParentDatabase

ParentDocumentUNID

ParentView

Responses

SaveMessageOnSend

SentByAgent

Signer

SignOnSend

Size

UniversalID

Verifier

Methods

AppendItemValue

AttachVCard

CloseMIMEEntities

ComputeWithForm

ConvertToMIME

CopyAllItems

CopyItem

CopyToDatabase

CreateMIMEEntity

CreateReplyMessage

CreateRichTextItem

Encrypt

GetAttachment

GetFirstItem

GetItemValue

GetItemValueCustomDataBytes

GetItemValueDateTimeArray

GetMIMEEntity

GetRead method

GetReceivedItemText

HasItem

Lock

LockProvisional

MakeResponse

MarkRead

MarkUnread

New

PutInFolder

Remove

RemoveFromFolder

RemoveItem

RemovePermanently

RenderToRTItem

ReplaceItemValue

ReplaceItemValueCustomDataBytes

Save

Send

Sign

UnLock

Creation

To create a new NotesDocument object, use one of the following:

  • New
Note: The New method is not supported in COM.
  • CreateDocument method in NotesDatabase

Given a database, New creates a document in the database and returns a NotesDocument object that represents the document. You must call Save if you want the new document to be saved to disk.

Syntax

Dim variableName As New NotesDocument( notesDatabase )

or

Set notesDocument = New NotesDocument( notesDatabase )

Parameters

notesDatabase

The database in which to create a new document.

Access

There are several ways to access an existing document.

  • To get a document based on its position in a view, use a NotesView.
  • To get a document based on its position in a response hierarchy, use a NotesView.
  • To get a document based on its note ID or UNID, use GetDocumentByID or GetDocumentByUNID in NotesDatabase.
  • To get all the documents in a database, use AllDocuments in NotesDatabase.
  • To get all the documents that match a full-text search query of a view or a database, use FTSearch in NotesView or NotesDatabase.
  • To get all the documents in a database that meet search criteria, where the criteria are defined using formula language, use Search in NotesDatabase.
  • To get documents in a database that have not been processed by the current agent, use UnprocessedDocuments, UnprocessedFTSearch, or UnprocessedSearch in NotesDatabase.
  • To get all of the documents that are responses to a particular document, use the Responses property in NotesDocument.
  • To get a response document's parent document, use the ParentDocumentUNID property in NotesDocument and the GetDocumentByUNID method in NotesDatabase.

Once you have a view, you can navigate to a specific document using methods in the NotesView class.

Once you have a collection of documents, you can navigate to a specific document using methods in the NotesDocumentCollection class.

Note: NotesDocument objects are cached in RAM for better performance. When you're done with them you should use the Delete statement to remove them from cache to recover the memory.

Saving changes

After you create, modify, or delete a document, you must save the changes by calling the Save method.

If you don't call Save before the script finishes, all of your changes to a NotesDocument are lost. Call Save every time you want to keep your changes.

When you call Save, the document is saved to disk even if you don't add any items to it.

Additional properties

In addition to the properties listed, you can also treat an item name as a property of a NotesDocument object. For example, the following line of script sets the value of the Subject item in a document to "Hello":

doc.Subject = "Hello"

For more information, see the AppendItemValue and ReplaceItemValue methods.

Encryption

A script attempts to decrypt an encrypted document the first time the script accesses one of the NotesDocument properties or methods. If decryption fails, an error is raised.

Example