getEntryByKey (NotesView - JavaScript™)
Finds a view entry of type document based on its 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 the first entry with column values that match the keys.
Defined in
NotesViewSyntax
getEntryByKey(key:any) : NotesViewEntry
getEntryByKey(keys:java.util.Vector)
: NotesViewEntry
getEntryByKey(key:any,
exact:boolean)
: NotesViewEntry
getEntryByKey(keys:java.util.Vector,
exact:boolean)
: NotesViewEntry
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 |
---|---|
NotesViewEntry |
The first entry in the view with column values that match the keys. Returns null if there are no matching entries. |
Usage
For this method to work, you must have at least one column sorted for every key in the vector.This method returns only the first entry with column values that match the strings you indicate. To locate all matching entries, use getAllEntriesByKey.
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." This method is similar to getDocumentByKey.
If any columns are formatted with both categories and subcategories in the same column (using the "\\" special character), the method will not find the entry.
Examples
This button gets the first document in a view whose first sorted column starts with a specified string.var v:NotesView = database.getView("main");
var entry:NotesViewEntry = v.getEntryByKey(requestScope.query);
if (entry == null) {
requestScope.status = "No subject starting with that query";
return;
}
requestScope.status = entry.getDocument().getItemValueString("subject");
var v:NotesView = database.getView("categorized");
var query = new java.util.Vector();
query.addElement("Category 1");
query.addElement(requestScope.query);
var entry:NotesViewEntry = v.getEntryByKey(query);
if (entry == null) {
requestScope.status = "No subject starting with that query";
return;
}
requestScope.status = entry.getDocument().getItemValueString("subject");