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



Mar 10, 2012, 7:10 AM
46 Posts

'range' is undefined and cannot be accessed as an array

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 8.5.2
  • Role:
  • Tags:
  • Replies: 4
Hi, I have a problem with javascript.
The strange thing is that there is this error when I run the application on localhost - appears only on the production server

Exception

Error while executing JavaScript computed expression
Script interpreter error, line=10, col=14: 'range' is undefined and cannot be accessed as an array

JavaScript code

   1: var range = @DbColumn("","data",1);
   2: 
   3:     function rand(range_from,range_to)
   4:         {
   5:             var r = Math.random();
   6:             r = r * (range_to-range_from) + range_from;
   7:             return Math.round(r);
   8:         }
   9: 
  10: var result = range[rand(0,range.length-1)];
  11: 
  12: return result
Mar 12, 2012, 10:52 AM
272 Posts
Re: 'range' is undefined and cannot be accessed as an array
Hi,
 
you are trying to access a undefined value, that is why it is not working. 
Maybe the lookup is not correct. Please check your @DBColumn: Is the view existing / a view index build?
 
Hope this helps 
Sven
 
Mar 13, 2012, 2:21 PM
46 Posts
Re: 'range' is undefined and cannot be accessed as an array
Everything seems to be correct.
Is there another way to get a random value from a column?
 
Mar 13, 2012, 3:46 PM
272 Posts
Re: 'range' is undefined and cannot be accessed as an array
Script interpreter error, line=10, col=14: 'range' is undefined and cannot be accessed as an array
 
This happens if @DbColumn has no returning value.
 
Sven
 
Mar 23, 2012, 2:15 PM
46 Posts
Re: 'range' is undefined and cannot be accessed as an array
In the column, there are some values.
The strange thing is that the error only occurs on the server.

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