getNthDocument (NotesView - JavaScript)

Returns the document at a specified position in the top level of a view.

Defined in

NotesView

Syntax

getNthDocument(n:int) : NotesDocument
Parameter Description
n A number indicating the document to return. Use 1 to indicate the first document in the view, 2 to indicate the second document, and so on. If this value is an XPage control, you must force it to an integer even if the control is numeric.
Return value Description
NotesDocument The document in the nth position in the view. Returns null if there is no document at the specified position.

Usage

This method accesses only top-level (main) documents in a view; response documents are excluded.

In a categorized view, this method returns only the first document in each main category (not each subcategory).

If you do not have reader access to the specified document, this method returns the next document to which you have reader access. If you increment n, the increment is relative to the actual value of n, not the document that was accessed. So you will access the same document repeatedly until that document actually is the nth document.

Using this method to iterate through a loop is strongly discouraged for performance reasons. See getNextDocument, getNextSibling, getPrevDocument, and getPrevSibling for the preferred loop structures.

Examples

This button gets the document in a view associated with the XPage at a specified top-level position.
var doc:NotesDocument = view1.getNthDocument(requestScope.query * 1);
if (doc != null) {
	requestScope.status = doc.getItemValueString("subject");
} else {
	requestScope.status = "No document at that position";
}