getPrevDocument (NotesDocumentCollection - JavaScript™)
Gets the document immediately preceding the current document or a specified document in a collection.
Defined in
NotesDocumentCollectionSyntax
getPrevDocument() : NotesDocument getPrevDocument(doc:NotesDocument) : NotesDocument
| Parameter | Description |
|---|---|
doc |
Any document in the collection. Cannot be null. |
| Return value | Description |
|---|---|
NotesDocument |
If no parameter, the document preceding the current document. If a parameter, the document preceding the specified document. If there is no previous document, returns null. |
Usage
The preferred loop structure isgetLastDocument() followed
by getPrevDocument() until it returns null. For performance
reasons, you should avoid using getNthDocument(n:int) and getPrevDocument(doc:NotesDocument) in
a loop.Getting documents in a loop quickly depletes dynamic memory.
To avoid memory problems, recycle the NotesDocument object
on each iteration with a sequence similar to this: var tmpdoc
= getPrevDocument(); doc.recycle(); doc = tmpdoc.
Examples
This button gets all the documents in the current database in reverse order.var dc:NotesDocumentCollection = database.getAllDocuments();
var doc:NotesDocument = dc.getLastDocument();
while (doc != null) {
requestScope.status += "\n" + doc.getItemValueString("subject");
var tmpdoc:NotesDocument = dc.getPrevDocument();
doc.recycle();
doc = tmpdoc;
}This button gets the next to the last document in
the current database.
var dc:NotesDocumentCollection = database.getAllDocuments();
if (dc.getCount() > 1) {
var doc:NotesDocument = dc.getPrevDocument(dc.getLastDocument());
requestScope.status = doc.getItemValueString("subject");
doc.recycle();
}