@DbLookup (JavaScript)

Returns view column or field values that correspond to matched keys in a sorted view column.

Defined in

@Functions (JavaScript)

Syntax

@DbLookup(dbName:string, viewName:string, key:string, colNumber:int) : any

@DbLookup(dbName:string, viewName:string, key:string, fieldName:string) : any

@DbLookup(dbName:string, viewName:string, key:string, colNumber:int, keywords:string) : any

@DbLookup(dbName:string, viewName:string, key:string, fieldName:string, keywords:string) : any

Parameter Description
dbName An array of two elements where the first element is the name of the server, and the second element is the name of the database. You can use empty quotes for the current server. For the current database, you can use empty quotes instead of the array, or you can use an array with empty quotes for each element.
viewName Name of a view in the database.
key A value to be matched against the first sorted column in the view.
colNumber Number of a column in the view starting at 1. If a column number is used, the return values are taken from this column in the view.
fieldName Name of an item in the documents in the view. If an item name is used, the return values are taken from this item in the documents from which the view data is drawn.
keywords One or more comma-separated strings containing the following values:
  • [FAILSILENT] returns "" (null string) instead of an error if the key cannot be found.
  • [PARTIALMATCH] returns a match if the key matches the beginning characters of the column value.
  • [RETURNDOCUMENTUNIQUEID] returns the UNID of the document instead of a field or column value.
Return value Description
any An array containing the column or item values.

Usage

This formula compares key against the values in the first sorted column in the view, and wherever a match occurs, returns either:
  • The corresponding value in the column specified by colNumber.
  • The data element specified by fieldName in the corresponding document.

Examples

The following example is the data binding formula for a list box. The rendered list box contains the values from column 2 of All where the corresponding value in the first sorted column is blue.
@DbLookup(@DbName(), "All", "blue", 2);

The following example is the data binding formula for a list box. The rendered list box contains the values from the data element Subject where the corresponding value in the first sorted column is blue.

@DbLookup(@DbName(), "All", "blue", "Subject");