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



Jan 20, 2012, 1:50 PM
46 Posts
topic has been resolvedResolved

DbColumn range

  • Category: Server Side JavaScript
  • Platform: Windows
  • Release: 8.5.2
  • Role: Developer
  • Tags: DbColumn,range
  • Replies: 2
Why can not I set the range of the DBColumn:
 
var range = @DbColumn("","alle",1);

    function rand(range_from,range_to)
        {
            var r = Math.random();
            r = r * (range_to-range_from) + range_from;
            return Math.round(r);
        }

var result = range[rand(0,range.length-1)];

return result
 
if I change
var range = @DbColumn("","alle",1);
 
to
 
var range = ['aaa','bbb','ccc']; 
 
then the scope is working properly.
 
Have any idea how to improve?
Jan 23, 2012, 2:49 PM
38 Posts
Re: DbColumn range
 I think that the problem is @DbColumn will return a Vector and not an Array.
 
Jan 25, 2012, 1:02 PM
46 Posts
Re: DbColumn range
Problem resolved :)
My mistake - the column in the view was empty:
 
This script works correctly:
 
 
var range = @DbColumn("","alle",1);

    function rand(range_from,range_to)
        {
            var r = Math.random();
            r = r * (range_to-range_from) + range_from;
            return Math.round(r);
        }

var result = range[rand(0,range.length-1)];

return result
 
Pozdrawiam Tomek

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