dominoGuru.com
Your Development & Design Resource
Quicktip: Web DBLookup API
03/03/2008 03:50 PM by Chris Toohey
This is quick-and-dirty, and something that I just put together for a friend of mine who's working on an ever-expanding (scope, that is...) project. It's simple and gets the job done, but can offer both an insight into more advanced architectures as well as a near-limitless application.
Let's take a look at the @DBLookup
Function in all it's
glory:
@DbLookup( class : cache ; server : database ; view ; key ; fieldName ;
keywords )
We'll go with the cookbook method:
Ingredients
- 1 Form Design Element
- 1 Navigator Design Element
Long list - I know.
So, we'll start by creating a blank Navigator design element named "dblookup". Now, create a Form design element called "$$NavigatorTemplate for dblookup", setting the Content Type to "text/plain", and adding the following fields:
- SaveOptions
- Set to "0", since I don't want this to ever generate content - just render it!
- Body
- Which will be a Computed Rich Text field - see Formula below...
The Body Formula:
@DbLookup( @URLQueryString("class") : @URLQueryString("cache") ;
@URLQueryString("server") : @URLQueryString("database") ;
@URLQueryString("view") ; @URLQueryString("key") ; @URLQueryString("fieldName")
; @URLQueryString("keywords") )
Disgusting isn't it?!
It's usage:
db.nsf/dblookup?open&cache=NoCache&view=someviewname&key=somekeyvalue&fieldName=
returnfieldName&keywords=%5BFAILSILENT%5D
This, as you can see, will do a "NoCache" DBLookup in the current database against the someviewname View for somekeyvalue, returning the value from the NotesItem returnfieldName, and returning "" (blank) when the lookup fails.
The reason that I'm using Plain Text as the Content Type is to allow for usage with AJAX functions, and the Rich Text is used to allow bigger lookups. Need it to do something more, expand away!