TOC : Script API > JavaScript > JavaScript API > Component > ReportTemplate > Method >

 

SetGlobal

<< Click to Display Table of Contents >>

Navigation:  »No topics above this level«

TOC : Script API > JavaScript > JavaScript API > Component > ReportTemplate > Method >

 

SetGlobal

 

 

Sets the global variables.

 

 

 

Prototype :

 

void SetGlobal

(

        string Key,

        var GlobalObject

)

 

 

 

Arguments :

 

Key

name of Global variable

GlobalObject

global variable object

 

 

 

Reference :

 

The global variables defined with the Key is effective only in one report template.

 

The global variables of string, numbers, arrays can be set.

 

String and numbers are allowed in any event. Arrays are allowed only in the same event group.

 

 

 

Example :

 

//define a Global object of text type

  ReportTemplate.SetGlobal("Title", "OZ Report");

//get the Global object set as text type

  _TraceLn(ReportTemplate.GetGlobal("Title"));

 

//define a Global object of JSON string

  ReportTemplate.SetGlobal("DeptCode", "[{\"code\":\"100\"}, {\"code\":\"200\"},{\"code\":\"300\"}]");

//get the Global object set as JSON string

  var arrTemp = JSON.parse(ReportTemplate.GetGlobal("DeptCode"));

  for(i=0; i<arrTemp.length; i++) {

     _TraceLn(arrTemp[i].code);

  }

 

//define a Global object as an array

  var Values = new Array();

  Values[0] = 100; Values[1] = 200; Values[2] = 300;

  ReportTemplate.SetGlobal("DeptCode", Values);

//get each element of Global object array

  var arrTemp = ReportTemplate.GetGlobal("DeptCode");

  for(i=0; i<arrTemp.length; i++) {

     _TraceLn(arrTemp[i]);

  }

 

 

 

Available Events :

 

All Events