Trying to Demo the "Power of Xpages"

Just trying to do a “simple” join in a computed column in a view control on an Xpage. I have searched for an example and have not been able to locate one.

What works: Using @Dblookup to another view in the same database.

What does not return data: @DbLookup to same view in another database.

Code that is working:

var key = viewRow.getColumnValue(“Project Code”);

var lookup = @DbLookup(@DbName, “xEventsByProjectCode”, key, 2);

return lookup

Code that is not working:

var key = viewRow.getColumnValue(“Project Code”);

var lookup = @DbLookup(“Intranet\Events.nsf”, “xEventsByProjectCode”, key, 2);

return lookup

Does anyone know

  1. Is this possible?

  2. If possible am I supposed to be specifying the server name? Or is the database sytax incorrect?

Thanks for any help in advance. I apologize if this is trivial knowledge.

Subject: Have you looked at this example?

Nathan Freeman has a good example posted here: http://www.lotus911.com/nathan/escape.nsf/d6plinks/NTFN-7FRG79

-John

Subject: ooops…just re-read your post

The example I posted is only using lookups within the same db, sorry.

-John

Subject: Actually working off one Nathan’s samples :slight_smile:

Does the servername/dbname need to be in a JavaScript array?

Elijah

Subject: It’s possible :slight_smile:

It’s possible to lookup from a different database and view as I’ve done it :slight_smile: Unfortauntly not many places have posted HOW you actually do it.

The trick is to use an array believe it or not with the server and database.

var db1 = new Array(Server,DatabaseName);

var results = @DbLookup(db1, view,key, colnumber);

Don’t forget to escape the slashes as this is javascript:-

i.e. Server: ‘SERVERNAME/ORG’ or database: ‘folder\databasename.nsf’

Also you mentioned you wanted to do a simple ‘join’. ‘Join’ is a lotusScript function and xpages won’t undertsand this (as far as I know). You’ll actually need to use @implode instead.

Hope that helps.

Subject: Thanks! It worked!

Here is the final working code for the computed column, in the view control, on an xpage, in a pear tree.

var key = viewRow.getColumnValue(“Column Name in the View Control”);

var db1 = new Array(“YourServerName”, “Folder\Yourdatabase.nsf”);

var lookup = @DbLookup(db1, “ViewInTheOtherDatabase”, key, 2);

return lookup

Thanks all for the help!

Elijah