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



Jul 17, 2013, 6:21 PM
7 Posts
topic has been resolvedResolved

@DBLookup returns undefined

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 8.5.3
  • Role: Developer
  • Tags:
  • Replies: 5

Hi, I have a view with one column (the lookup key), where the key may be present 0, 1, 2, or 3 times.  For this particular path which is failing, there are three documents with the lookup key.

I do three lookups.

var fupvalues = @DbLookup(sessionScope.SurvDbName, "AGENTAllSurveys", lookupkey, "FollowUpRequired");

var retvalues = @DbLookup(sessionScope.SurvDbName, "AGENTAllSurveys", lookupkey, "Returned");

var retdate = @DbLookup(sessionScope.SurvDbName, "AGENTAllSurveys", lookupkey, "ReturnedDate");
 

The first two work fine.  Both return an array of three values.  These fields are initialized to "0" and sometimes reset to "1".  The correct values are returned for each of the three documents.

The third fails with retdate null.  When I try to substring retdate[i], I get undefined error.  Although, the ReturnedDate field is defined as a Date/Time field in the domino form, it is not initialized.  In the first document properties it shows as RETURNEDDATE with a value of "" and data type of Text.  In the other two documents, the RETRUNEDDATE field has values such as 07/11/2013 05:33:16 PM ZE8 and data type of Time/Date.

I was hoping for an array of three values where I didn't plan to look at the first one, just the last two.  I know it isn't there because the Returned flag is still "0".

I have tried to define var as var retdate:NotesDateTime   or   var retdate:Date with same results.  In addition, tried change ReturnedDate to RETURNEDDATE thinking it was a case issue. Also, tried to switch to @DBLookup with [RETURNDOCUMENTUNIQUEID] option, but it only returns the first id, not an array of all three.

Any ideas?

Sue

Jul 18, 2013, 1:08 AM
586 Posts
Thoughts

Sue,

I don't know the answer to your problem - I'm sure it as to do with it being a data field.  Sometimes adding "toJavaDate()" helps but I've not idea here.

In your case I would think about a different approach.  You're doing 3 @DbLookups in a row to the same view.  Even on the Notes Client that's not the best for performance.

I would abandon @DbLookups you don't need them here.  You can create a SSJS function - call that and bring back the 3 return values in one shot.  So only one call to open the view.  In the function you can get all your values, and return them as an array.  There's some information about that in this stackoverflow question.  http://stackoverflow.com/questions/9897636/how-to-pass-variable-parameters-to-an-xpages-ssjs-function

If you write the function in LotusScript first - that might help you in translating it to SSJS.  It would be pretty similar.

Just my 2 cents....

 

Dave

 

Jul 18, 2013, 2:17 PM
7 Posts
Thanks

Thanks for your thoughts.  I had seen your similar reply on others.  I tried the toJavaDate and get NaN.  It really feels like a bug in that only one value is coming back, instead of three.

Jul 18, 2013, 5:34 PM
586 Posts
hmm

I guess I don't get it...  But I confuse easily....

 

when you say you want 3 values back...  is the date field a multi-value field?  And you're getting 1 value but not all?  Maybe I missed that..

Does this work in LotusScript?  All @DbLookup really does under the covers is call a session.eval...  one of the several reasons why I don't like DbLookup...

 

You might want to break this down to the lowest common problem and post on StackOverFlow... smarter people then me check those out..

Jul 18, 2013, 8:54 PM
33 Posts
You could try using the Notes Classes

Excuse the code: I am typing it without benefit of a Domino Designer Client.  You could write this as a function and pass in the parameters to make it reusable

 

var db:NotesDatabase = session.getDatabase(sessionScope.SurvDbName);

var view:NotesView = db.getView('AGENTAllSurveys');

var coll:NotesDocumentCollection = view.getAllDocumentsByKey(lookupKey, true);

var doc:NotesDocument = coll.getFirstDocument();

var tmpDoc:NotesDocument;

var returnedValues:java.util.Vector = new java.util.Vector();

while(doc != null)

{

     tmpDoc = coll.getNextDocument(doc);

     returnedValues.add(doc.getItemValue('ReturnedDate'));

     doc.recycle();

     doc = tmpDoc;

}

 

...then you have the returnedValues Vector to do with what you will.  You can check each value to see if it is null or do a typeof to get its data type, or even both.

 

Jul 26, 2013, 2:30 PM
7 Posts
Thank Rob

Thanks, Rob, that is the solution I went with.  The field from each of the three docs is then available!


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