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



Feb 27, 2012, 11:32 AM
46 Posts
topic has been resolvedResolved

computedField - NaN

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 8.5.2
  • Role: End user,Developer
  • Tags:
  • Replies: 2
Hi, I have code like this, and if there is no value i get NaN - and I would have 0.

 
var Year = getComponent("comboBox1").getValue();
var keys = ["AA"+Year+"-22"]
var result = new Array();
var v = null; var i = 0;
for (i = 0; i < keys.length; i++)
   { v =@Sum(@DbLookup("","Report",keys[i],3));
   result.push(v);
   }
result

 
Feb 27, 2012, 3:41 PM
14 Posts
Re: computedField - NaN
Tomasz,
 
I didn't test it myself but I suppose if the view "report" has no document with the key key[i], then @DbLookup("","Report",keys[i],3) will return null => @Sum will fail because it cannot convert null to a number (NaN means Not A Number).
 
You should try this instead :
 
for (i = 0; i < keys.length; i++)
   {
    var lkp= @DbLookup("","Report",keys[i],3);
 
    if (lkp!=null) {
         v = @Sum(lkp);
        result.push(v);
    } else {
     result.push(0);
 }
 
Hope this helps.
 
Renaud
Feb 28, 2012, 7:28 AM
46 Posts
Re: computedField - NaN
This works perfectly.
 
Thanks Renaud

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