getAllDocumentsByKey (NotesView - JavaScript)

Finds documents based on their column values within a view. You create a key or vector of keys, where each key corresponds to a value in a sorted column in the view. The method returns all documents whose column values match the keys.

Defined in

NotesView

Syntax

getAllDocumentsByKey(key:any) : NotesDocumentCollection

getAllDocumentsByKey(keys:java.util.Vector) : NotesDocumentCollection

getAllDocumentsByKey(key:any, exact:boolean) : NotesDocumentCollection

getAllDocumentsByKey(keys:java.util.Vector, exact:boolean) : NotesDocumentCollection

Parameter Description
key A String, Number, NotesDateTime, or NotesDateRange object that is compared to the first sorted column in the view.
keys String, Number, NotesDateTime, or NotesDateRange objects that are compared to sorted columns in the view. The first element in the vector is compared to the first sorted column in the view; the second element is compared to the second sorted column; and so on.
exact Specify true if you want to find an exact match. If you specify false or omit this parameter, a partial match succeeds.
Return value Description
NotesDocumentCollection All documents in the view whose column values match each of the keys. If no documents match, the collection is empty and the count is zero.

Usage

For this method to work, you must have at least one column sorted for each key.

This method returns all the documents whose column values match the keys. To locate just the first document, use getDocumentByKey.

Documents returned by this method are in no particular order, and do not provide access to column values. Use getAllEntriesByKey for these capabilities.

Matches are not case-sensitive. For example, "Turban" matches "turban." In an exact match, "cat" matches "cat" but does not match "category," while "20" matches "20" but does not match "201." In a partial match, "T" matches "Tim" or "turkey," but does not match "attic," while "cat" matches "catalog" or "category," but does not match "coat" or "bobcat." The use of partial matches with multiple keys may result in missed documents. If the first key is partial and the second column does not sort the same with the partial key as with the exact key, documents that fall out of sequence are missed.

To get view entry information about the documents, use the getAllEntriesByKey method.

If any columns are formatted with both categories and subcategories in the same column (using the "\\" special character), the method will not find the documents.

Examples

This button gets all the documents in a view whose first sorted column starts with a specified string.
var v:NotesView = database.getView("main");
var dc:NotesDocumentCollection = v.getAllDocumentsByKey(requestScope.query);
if (dc.getCount() == 0) {
	requestScope.status = "No subjects starting with that query";
	return;
}
var doc:NotesDocument = dc.getFirstDocument();
while (doc != null) {
	requestScope.status += "\n" + 
		doc.getItemValueString("subject");
	var tmpdoc = dc.getNextDocument();
	doc.recycle();
	doc = tmpdoc;
}
This button gets all the documents in a view whose first sorted column starts with ???Category 1??? and whose second sorted column starts with a specified string.
var v:NotesView = database.getView("categorized");
var query = new java.util.Vector();
query.addElement("Category 1");
query.addElement(requestScope.query);
var dc:NotesDocumentCollection = v.getAllDocumentsByKey(query);
if (dc.getCount() == 0) {
	requestScope.status = "No subjects starting with that query";
	return;
}
var doc:NotesDocument = dc.getFirstDocument();
while (doc != null) {
	requestScope.status += "\n" + 
		doc.getItemValueString("subject");
	var tmpdoc = dc.getNextDocument();
	doc.recycle();
	doc = tmpdoc;
}