Manage Learn to apply best practices and optimize your operations.

@DBLookup function for Web

Learn how to simulate the @DBLookup function in a Web browser to return a Lotus Notes Domino array using some JavaScript code.

An alternative to simulate @DBLookup in the Web browser and to transfer the processing of the data to the

Web browser. The return of the data is a Lotus Notes Domino array.

Note: This is only available for Internet Explorer.

Example of the call:

cars = dbLookup("domino01",

          for (var i = 0; i < cars.length; i++)
                  alert("Values from lookup 
["+String(i)+"] = "+cars[i]);
function dbLookup(server,path,view,
        // server e path optional

        xmlDoc = new ActiveXObject
        xmlDoc.async = false;

        if (server != "") server = "http://"+ server;
        if (path != "") path = "/"+path +"/";

        vurl = trim(server)+trim(path)+view+


nodes = xmlDoc.documentElement.childNodes;

        temp = new Array(nodes.length);
        var j = 0;
          for (var i = 0; i < nodes.length; i++)

                          temp[j] =

        volta = new Array(j);
          for (var i = 0; i < j; i++)
                          volta[i] = temp[i];


function trim(sStr)
  var iI = 0;
  var iJ = 0;
  var iTam = 0;
  var sAux = "";

  iTam = sStr.length;
  if(iTam==0) return(sStr);

  for(iI=0; iI<iTam; iI++)
    if(sStr.charAt(iI)!=' ') break;

  if(iI >= iTam) return("");

  for(iJ=iTam - 1; iJ>=0; iJ--)
    if(sStr.charAt(iJ)!=' ') break;



The @DBLookup function for Web in the code at this line : vurl = trim(server)+trim(path)+view+"?readviewentries&count=10000"; we cannot have 10000 documents returned if in the server's document the maximum number of documents returned is for example 300. I Personnaly use this url it returns the maximum number of documents authortised by the server. vurl = trim(server)+trim(path)+view+"?readviewentries&count=-1"; (replace 10000 by -1).
—Zoubir A.

The problem with this approach is that the developer is creating an XML object for the entire view and then navigating through it. Not only is this inefficient but it could suck up a huge chunk of memory from the browser depending on the view size. What you should do is load a subset of view entries into the XML object instead of loading the entire view. This can be done by using the StartKey and UntilKey arguments of the ReadViewEntries call. I've included the help text from Domino explaining these arguments. StartKey = string Where: string is a key to a document in sorted view. The view displays at that document. In cases where there is no match for the StartKey, the next document is returned. So, for example, if the StartKey is "A" and there are no documents that begin with "A", StartKey returns the first document that begins with "B." UntilKey = string UntilKey is only valid when used with StartKey. It allows you to display the range of view entries beginning with the document specified by StartKey until the document specified by UntilKey. For example, &StartKey=A&UntilKey=B would give you all the entries that start with A. Use the &Count keyword to further limit the number of entries returned within any given range.
—Jerry B.

Do you have comments on this tip? Let us know.

This tip was submitted to the tip library by member Wesley Guisso. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

Dig Deeper on Lotus Notes Domino Administration Tools

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...