Locating documents within a view or folder in LotusScript® classes

First, find and set the view or folder to a NotesView object using the GetView method or the Views property of a NotesDatabase object.

Note: Views or folders must be public views or folders or private views or folders owned by the effective id running the agent and stored in the database. You cannot use LotusScript® to access private views or folders stored in the desktop.

Traversing a view

Use the GetFirstDocument (or GetLastDocument) method of NotesView, followed by a loop of GetNextDocument (or GetPrevDocument) methods to traverse all the documents in a view or folder.

Getting a document at a known position in a view

Use the GetNthDocument of NotesView to get a document at a known position within the top-level (main) documents of a view or folder. This method does not access response documents.

Subsetting a view with a full-text search

The FTSearch method of NotesView creates a subset of the view or folder consisting of documents that match a search query. The search query, specified as the first argument of FTSearch, is a string that meets the rules for full-text search queries. The rules require that a search entity be a single word or multiple words enclosed in quotes (double quotes in a LotusScript® string constant). Search entities can include ? and * wildcards, and can be combined by ! (not), & (and), and | (or) operators.

A database does not need to be full-text indexed for a search to work, but the search is slower. The UpdateFTIndex method of NotesDatabase creates or updates a full-text index. The IsFTIndexed property of NotesDatabase tests for the existence of an index.

After creating the subset view or folder, traverse it using GetFirstDocument (or GetLastDocument) of NotesView and GetNextDocument (or GetPrevDocument). The subsetted view is flat; that is, no response hierarchy exists.

Use the Clear method of NotesView to restore the full view or folder.

Subsetting a view with a sorted column key

Use the GetDocumentByKey method to find the first document in a view or folder that matches specified character strings in the sorted columns. For example, if columns 1 and 2 are sorted, you can specify one character string to find a match in the first column, or two strings to find a match in the second column after the first column is matched. You can specify a partial or exact match on the keys.

Use the GetAllDocumentsByKey method to find all documents in a view or folder that match specified character strings in the sorted columns. This technique does not set the ColumnValues property in the retrieved documents; if this is a concern, use GetDocumentByKey to find the first matching document, then use GetNextDocument to find subsequent documents that might also match -- you have to check that they do.

Working with response documents

Use the GetNextSibling and GetPrevSibling methods of NotesView to skip documents that are at a different level from the current document in the response hierarchy. For example, if you have accessed a main document that has response documents, GetNextSibling gets the next main document whereas GetNextDocument gets the first response document to the current main document.

Use the GetChild method to get the first document at the next lesser level to the current document. Use the GetParentDocument method to move up a level; you can also pass the ParentDocumentUNID property of NotesDatabase to the GetDocumentByUNID method.

Use the Responses property of NotesDocument to collect all the first-level responses for a document in a NotesDocumentCollection object. The object contains zero responses if the document is not a parent. To obtain response documents at subsequent levels, you must access the Responses property for every response document at each level. Documents collected in the Responses property do not have a particular order.

Use the IsResponse property of NotesDocument to see if a document is a response document.

Use the MakeResponse method to make one document a response to another.

Putting a document in a folder

Use the PutAllInFolder method of NotesDocumentCollection or the PutInFolder method of NotesDocument to copy documents to a public or private folder. Use the RemoveAllFromFolder method of NotesDocumentCollection or the RemoveFromFolder method of NotesDocument to remove a document from a public or private folder.