dominoGuru.com

Your Development & Design Resource

Quicktip: Web DBLookup API

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!


About the author: Chris Toohey

Thought Leadership, Web & Mobile Application Development, Solutions Integration, Technical Writing & Mentoring

A published developer and webmaster of dominoGuru.com, Chris Toohey specializes in platform application development, solutions integration, and evangelism of platform capabilities and best practices.



More from dominoGuru.com


dominoGuru.com is powered by IBM Notes Domino XPages & hosted by Prominic.NET

Contact Us

Use our Contact / Feedback form or one of these email addresses:

Creative Commons License

Except where otherwise noted, dominoGuru.com by Chris Toohey is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.