getNextDocument (NotesDocumentCollection - JavaScript™)
Gets the document immediately following the current document or a specified document in a collection.
Defined in
NotesDocumentCollectionSyntax
getNextDocument() : NotesDocument getNextDocument(doc:NotesDocument) : NotesDocument
| Parameter | Description |
|---|---|
doc |
Any document in the collection. Cannot be null. |
| Return value | Description |
|---|---|
NotesDocument |
If no parameter, the document following the current document. If a parameter, the document following the specified document. If there is no next document, returns null. |
Usage
The preferred loop structure isgetFirstDocument() followed
by getNextDocument() until it returns null. For performance
reasons, you should avoid using getNthDocument(n:int) and getNextDocument(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
= getNextDocument(); doc.recycle(); doc = tmpdoc.
Examples
This button gets all the documents in the current database.var dc:NotesDocumentCollection = database.getAllDocuments();
var doc:NotesDocument = dc.getFirstDocument();
while (doc != null) {
requestScope.status += "\n" + doc.getItemValueString("subject");
var tmpdoc:NotesDocument = dc.getNextDocument();
doc.recycle();
doc = tmpdoc;
}This button gets the second document in the current
database.
var dc:NotesDocumentCollection = database.getAllDocuments();
if (dc.getCount() > 1) {
var doc:NotesDocument = dc.getNextDocument(dc.getFirstDocument());
requestScope.status = doc.getItemValueString("subject");
doc.recycle();
}