getDocument (NotesDocumentCollection - JavaScript)

Gets a specified document in a collection.

Defined in

NotesDocumentCollection

Syntax

getDocument(doc:NotesDocument) : NotesDocument
Parameter Description
doc The document to be retrieved. Cannot be null.
Return value Description
NotesDocument The specified document. If the specified document is not in the collection, returns null.

Usage

This method gets a document in a document collection that is the same as a reference document that does not necessarily come from the collection (for example, a document retrieved from another collection). If the reference document is not in the collection, you get a null return.

This method throws an exception if the document collection is the result of a multi-database full-text search.

Examples

This button gets a collection of all documents in the current database and clones it. The first collection is then reduced to one document by a search. That document is used in the cloned collection to get the previous and next documents.
var dc:NotesDocumentCollection = database.getAllDocuments();
var clone:NotesDocumentCollection = dc.cloneCollection();
var query:string = requestScope.query;
if (!query.isEmpty()) {
	query = "\"" + query + "\"";
	database.updateFTIndex(true);
	dc.FTSearch(query, 1);
	var doc:NotesDocument = dc.getFirstDocument();
	if (doc != null) {
		requestScope.status = "";
		var doc2:NotesDocument = clone.getDocument(doc);
		var doc1:NotesDocument = clone.getPrevDocument();
		var doc3:NotesDocument = clone.getNextDocument();
		if (doc1 != null) {
			requestScope.status += 
				"\nPrevious: " + doc1.getItemValueString("subject");
		}
		if (doc2 != null) {
			requestScope.status += 
				"\n" + doc2.getItemValueString("subject");
		}
		if (doc3 != null) {
			requestScope.status += 
				"\nNext: " + doc3.getItemValueString("subject");
		}
	} else {
		requestScope.status = "No hit"
	}
} else {
	requestScope.status = "No query"
}