This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Aug 15, 2011, 2:37 PM
10 Posts
topic has been resolvedResolved

@DBLookup of an external database in Javascript

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 8.5.2
  • Role:
  • Tags:
  • Replies: 6
I'm running 8.5.2 on client and server and am having issues with the following code:
 
 

try{

var acronym = getComponent("comboBox1").getValue();

var db = Array("notea02a/SERV/Srs","Apps - SystemFolders\NotesSystemFolders.nsf");

var list = @DbLookup(db,"(By Acronym)", acronym, "CMISFullName");

if (@IsError(list))

return "Please select a valid acronym";

else

return list;

}catch (e){

return "Please select an acronym first (Error)";

}

 
No matter what I do, I get the error return.  I've verified that the view name and field name are correct, but still no dice.  I'm new to Javascript and XPages so, I'm sure it's something I missed.
 
Any help would be appreciated.
 
MJ  

Aug 15, 2011, 3:02 PM
272 Posts
Re: @DBLookup of an external database in Javascript
Hi,
 
instead of returning "Please select an acronym first (Error)" you could do return the error.
 
Just change the line
 
   return "Please select an acronym first (Error)";
 
to 
 
   return e
 
and check the message.
 
Sven
Aug 15, 2011, 3:25 PM
10 Posts
Re: @DBLookup of an external database in Javascript
Ok, when I did that, all I got was:
 
Error: "e" not found. 
 
MJ 
Aug 15, 2011, 5:08 PM
298 Posts
need two backslashes?
var db = Array("notea02a/SERV/Srs","Apps - SystemFolders\\ NotesSystemFolders.nsf");
Aug 15, 2011, 5:10 PM
272 Posts
Re: @DBLookup of an external database in Javascript
"e" is the variable in the catch-block. If it is not found, it sounds to me that you have a syntax problem in your code.
Try to rebuild the fragments of your code.
 
Remove the code in the try{} - section. Then there should be no error anymore.
 
 
Aug 16, 2011, 11:09 AM
6 Posts
Re: @DBLookup of an external database in Javascript

 
 i couldn't get that to work either so i did a workaround :-)
 
// get the data from the setup
    var sdoc:NotesDocument = session.getCurrentDatabase().getView('vwluSetup').getFirstDocument();
    var nab_server:String = sdoc.getItemValueString('fldNABServer');
    var nab_path:String = sdoc.getItemValueString('fldNABPath');
    var nab_view:String = sdoc.getItemValueString('fldNABView');
 
//conect the external db
var directory:NotesDatabase = session.getDatabase(nab_server, nab_path);
var allUsers:NotesView = directory.getView(nab_view);

var searchValue:string = 'whatever_to_search_for';
var matchingEntries:NotesViewEntryCollection = allUsers.getAllEntriesByKey(searchValue, false);
var entry:NotesViewEntry = matchingEntries.getFirstEntry();
 
 
Aug 16, 2011, 12:34 PM
10 Posts
Re: @DBLookup of an external database in Javascript
Well, I feel pretty stupid to tell you what the problem was but here it is:
 
 

var db = new Array("notea02a/SERV/Srs","Apps - SystemFolders\\NotesSystemFolders.nsf"); 

 
 I forgot to put two backslashes in the file path.  I found it when I had the error return the value of the db variable.
 
Oh well, live and learn. 
 
Thanks for all the help. 
 
MJ 
 


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal