Subscribe via Feed

Binding XPages to External Databases - Watchout!

David Leedy, May 27, 2010 12:31:51 PM

I'm working on a small app for my sales department.  They work offline in a totally disconnected state.  They have all their customer information in a series of Notes databases and they run 8.5.1 standard and replicate every night for updates. 

I've been asked to add a "Pricing Request" form to the application.  Since the long range plan is to convert the whole app to all XPages, I did not want to code this for the notes client.  I figured that I'd use XPages for this piece so it can run in the client or in the browser.  1 less thing to do in the future.

So I've been working on this app for a bit and have primarily been testing via the web browser.  The UI will not be fancy so I don't anticipate much difference between a browser and XPages In the Notes Client regarding any rendering issues.

Yesterday I wanted to give an "Alpha" version to a user so I can start getting some feedback.  So I go to test it in the Notes Client with the database running on the server and guess what?  It does NOT work.  It would not open the database that I was binding to!  It just made no sense. Of all the things that might not have worked the data binding was a problem?  Especially since it DID work for at least 1 database, but I couldn't get it to work for any others. 

I tried everything I could think of to fix it myself. I messed with ACLS....  I copied db's.... I moved db's out of sub-directories.... I said more then a few choice words.... I prayed to the Hockey Gods... I randomally deleted Users.... Nothing helped.

The original formula that I used to bind to the database was:

session.getDatabase(database.getServer(), "dbname.nsf")

Again - this worked great from the browser and for 1 database in the notes client.

When it became clear that I was dead in the water I reached out to friends on bleedyellow IM, twitter and email.  I talked to a couple of people who gave me good suggestions but no success.  Next would have been IQJam or a blog plea but I was too tired at that point.

This morning I woke up and came to work to find one of the best emails ever.  The XPage Genius's at IBM, Mr. Paul Hannan and Mr. Steve Castledine came to my rescue with an improved formula that seems to allow me to bind to a foreign database on the Web and in the Notes Client (Server and Local). I'm seriously considering having my wife engrave this on a plaque for me so I never forget it.

The formula is:


Why this works when the other does not I do not know. I believe there already is an SPR for this issue and it's slated to be fixed in 8.5.2. I don't know if this has been blogged about before and I forgot it.  The syntax seems familiar so I'm sure I've seen it before somewhere.

A HUGE Thanks to Paul and Steve and everyone else I talked to for helping me!!!

9 responses to Binding XPages to External Databases - Watchout!

John Jaeckle, April 14, 2011 1:38 AM

If i am understanding this correctly, This bug sitll exists in the Notes Client in 8.52, but not in a browser. My solution was to not use the built in "Open XPage option) but rather create a custom URL for the column I wanted the link in and open an xpage with that URL and then pass the target UNID to that xpage.
(http:/thisserver/thisdb/yourXpage.xsd?open&documentID=xxxx). However in the Notes client, this forces the user to have to login. Are we talking about the same issue? Any ideas on how to get rid of the login? I've tried using "notes://" as opposes to "http://" but no joy.

David Leedy, November 11, 2010 9:57 PM


Thanks for adding the snippet. I've not tried this on 8.5.2 yet so there might be differences. One thing I should point out which might not have been clear in the post is that my original solution:


Was used in the binding of the view at the datasource level. So no array was needed. You're right though and it's my understanding that @DbLookup does want an array passed in.

thanks for sharing the code!

John C, November 11, 2010 8:20 PM

After messing around on 8.5.2 I user the following:

db = Array(@Subset(@DbName(),1), "dbname.nsf"));
@DbLookup(db, 'View', 'Value', 2)

The code did not seem to work until I used it as an ARRAY. The it would work on all THREE:
Client, Web AND LocalHost

David Leedy, July 23, 2010 6:15 PM


And have you tried sess.getDatabase(srvr, extdb) on XPages In the Notes Client? That's where I had the problem. The server worked just fine but when I tried to run the app on local database in Notes Client - no luck. Actually I had one database that did work but not the one I wanted. I could not get 5-6 other tested databases to work. All the ACL's were the same. It was very weird.
But the older style code: @Name("[CN]",@Subset(@DbName(),1))+"!!dbname.nsf" worked in both.

markb, July 22, 2010 9:29 PM

sess.getDatabase(srvr,extdb) works for me on 8.5.1 except when there is an access problem, i.e. if the user running the XPage does't have access to extdb. The runtime error gives no clue that it is just an access issue but if you get something like this check the users access before you start hacking your script to bits.

Error while executing JavaScript computed expression
Script interpreter error, line=11, col=34: Exception occurred calling method NotesSession.getDatabase(string, string) null

Atul Saxena, June 1, 2010 1:30 PM

I used the following formula, to pull user's from Name & Address book (But you need to install FP2 on server)

// Server Side JavaScript
db = new Array(@Subset(@DbName(),1),"names.nsf");
return @DbColumn(db,"$VIMPeople",1);

Lars Berntrop-Bos, May 28, 2010 12:28 AM

The syntax look familiar because this is what you need to use for referencinf other db's on a server in Outlines.

It's also used in other places.

Steve Castledine, May 27, 2010 2:14 PM

Theres an associated Designer fix for this as well for 8.5.2, when selecting the server for an alternate database. The problem was you "had" to select a server whereas in most cases it was on the same server as the starting nsf. This then leads to hardcoded server names being used, which is not great :)

Usual caveats with future stuff.

Paul Hannan, May 27, 2010 1:50 PM

Hi Dave,
This is an 851 bug (PHAN82DK5F) which has been fixed in 852. The workaround above will work but it can be a real pain if you got to hard code references to external apps all over the place. The fix in 852 should resolve this.

Why does it happen? It's down to the runtime, all two of them - the Domino server has one and XPages in the client (XPiNC) has another (both are the same unless they are different versions). On XPiNC the runtime is local and so the 'server' is local and the app will attempt look up another app on the 'local' server which just isn't there. This is the failure. Now all we have to do then is get the correct server name rather than the local - hence the above workaround.

Real sorry for the cause of your sleepless night.