InetSoft Product Instructions: Reporting JavaScript Object Reference

Style Intelligence provides a few global functions in addition to those defined by the standard JavaScript runtime (see Appendix JS:General JavaScript Functions). This section presents the additional functions.


BI Demo Register
JavaScript

addParameter(name, default, type, alias, hidden)

Adds a parameter to the report. This function is available only within the onInit Handler, and is equivalent to defining a report parameter using the 'Parameter Definition' dialog box in Report Designer.

Parameters

parameter name name of the parameter (String)
parameter default parameter default value
parameter type one of the constants defined in XType
parameter alias label (String) to use when prompting
hidden flag Boolean:
false (default): prompt user
true: do not prompt user

Example

 addParameter('start_time', new Date(), XType.DATE,
    'Start date', false); 

The 'hidden' flag allows you to suppress user prompting for the parameter, equivalent to deselecting the 'Prompt User' option in the 'Parameter Definition' dialog box.

newInstance(name)

Creates a new Java object.

Parameters

 class name (String) 

Example

 var presenter = newInstance('inetsoft.report.painter.IconCounterPresenter'); 

You can usually accomplish the same thing using the 'new' operator, but this sometimes does not handle Java packages correctly.

getImage(string)

Loads an image file from a Java resource or string. The getImage() method checks whether the argument specifies a valid resource. If it does not specify a resource, then getImage() treats the parameter as an encoded image. Both ASCII Hex and ASCII85 are supported (useful for XML data).

Parameters

 image file resource path or URL to an image
    or
 ascii hex or ascii85 encoded gif/jpeg image data 

Example

 var img = getImage('/com/mypackage/icon.gif');
 img =  getImage('http://chart.inetsoft.com/images/inetsoft.png'); 

Example

 // picture column is ascii85 encoded gif image
 for(var r = 1; r < table.length; r++) {
    var img = getImage(table[r]['picture']);
    table[r]['picture'] = img;
 }

isNull(object)

Tests for null value.

Parameters

a report object 

Example

 if(isNull(Text1.text)) {
   // perform action when text for element Text1 is null
 }

docInfo(string)

Returns information specified in the Document Info tab of Report Designer.The fields include the following:

  • report.title
  • report.subject
  • report.author
  • report.keywords
  • report.comments
  • report.created
  • report.modified
  • report.format
  • report.format (available in onPrint Handler only).

Parameters

string containing document property (e.g., 'report.title') 

Example

var text = docInfo['report.title'];

log(string)

Prints a log message to the server log. If the script is running inside Report Designer, the log message is displayed in the Console window.

Parameters

 log message string 

Example

 log('onLoaded called');

runQuery(query_name [,parameters])

Returns a result set as a two-dimensional array that can be assigned to a Table, Chart, or Section.

Parameters

query_name
 a string containing the query name
parameters
 (optional) a two dimensional array string array, each row containing 
 a name value pair that corresponds to a query parameter

Example

var rs = runQuery('orders',[['category','Business'],['price',100]]);