Child pages
  • JSVariable

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
{div:style=}
Wiki Markup
Div
styledisplay:none

DO

NOT

EDIT

THE

CONTENT

OF

THIS

PAGE

DIRECTLY

(EXCEPT

INSIDE

THE

DIV

BELOW

WITH

ID=DESCRIPTION),

UNLESS

YOU

KNOW

WHAT

YOU'RE

DOING.


THE

STRUCTURE

OF

THE

CONTENT

IS

VITAL

IN

BEING

ABLE

TO

AUTO

UPDATE

THE

CONTENT

THROUGH

THE

DOC

GENERATOR.

\\ \\ Enter additional information related to this



Enter additional information related to this 'class'

inside

the

\

{div}

macro

with

'id=description'

{div} {div:id=description}{div}\\ {table:id=|class=servoy sSummary}{colgroup}{column:width=80px|padding=0px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Constants Summary{th}{tr}{tbody}{tr}{td}[Number]{td}{td}[#DATETIME] Constant to be used when the type of a variable needs to be specified.{td}{tr}{tbody}{tbody}{tr}{td}[Number]{td}{td}[#INTEGER] Constant to be used when the type of a variable needs to be specified.{td}{tr}{tbody}{tbody}{tr}{td}[Number]{td}{td}[#MEDIA] Constant to be used when the type of a variable needs to be specified.{td}{tr}{tbody}{tbody}{tr}{td}[Number]{td}{td}[#NUMBER] Constant to be used when the type of a variable needs to be specified.{td}{tr}{tbody}{tbody}{tr}{td}[Number]{td}{td}[#TEXT] Constant to be used when the type of a variable needs to be specified.{td}{tr}{tbody}{table}\\ {table:id=|class=servoy sSummary}{colgroup}{column:width=80px|padding=0px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Property Summary{th}{tr}{tbody}{tr}{td}[String]{td}{td}[#defaultValue] The default value of the variable.{td}{tr}{tbody}{tbody}{tr}{td}[String]{td}{td}[#name] The name of the variable.{td}{tr}{tbody}{tbody}{tr}{td}[Number]{td}{td}[#variableType] The type of the variable.{td}{tr}{tbody}{table}\\ {table:id=|class=servoy sSummary}{colgroup}{column:width=80px|padding=0px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Method Summary{th}{tr}{tbody}{tr}{td}[String]{td}{td}[#getScopeName]\() Get scope name{td}{tr}{tbody}{table}\\ {table:id=constant|class=servoy sDetail}{colgroup}{column:width=100%|padding=0px}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Constants Details{th}{tr}{tbody:id=DATETIME}{tr:id=name}{td}h6.DATETIME{td}{tr}{tr:id=des}{td}{div:class=sIndent}Constant to be used when the type of a variable needs to be specified.{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Number]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}

Div
iddescription



HTML Table
id
classservoy sSummary
Colgroup Tag
Col
width80px
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Constants Summary
Table Row (tr)
Table Cell (td)
Number
Table Cell (td)
DATETIME
Constant to be used when the type of a variable needs to be specified.
Table Row (tr)
Table Cell (td)
Number
Table Cell (td)
INTEGER
Constant to be used when the type of a variable needs to be specified.
Table Row (tr)
Table Cell (td)
Number
Table Cell (td)
MEDIA
Constant to be used when the type of a variable needs to be specified.
Table Row (tr)
Table Cell (td)
Number
Table Cell (td)
NUMBER
Constant to be used when the type of a variable needs to be specified.
Table Row (tr)
Table Cell (td)
Number
Table Cell (td)
TEXT
Constant to be used when the type of a variable needs to be specified.



HTML Table
id
classservoy sSummary
Colgroup Tag
Col
width80px
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Property Summary
Table Row (tr)
Table Cell (td)
String
Table Cell (td)
defaultValue
The default value of the variable.
Table Row (tr)
Table Cell (td)
String
Table Cell (td)
name
The name of the variable.
Table Row (tr)
Table Cell (td)
Number
Table Cell (td)
variableType
The type of the variable.



HTML Table
id
classservoy sSummary
Colgroup Tag
Col
width80px
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Summary
Table Row (tr)
Table Cell (td)
String
Table Cell (td)
getScopeName()
Get scope name



HTML Table
idconstant
classservoy sDetail
Colgroup Tag
Col
colspan2
width100%
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Constants Details
Table Body (tbody)
idDATETIME
Table Row (tr)
idname
Table Cell (td)

DATETIME

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Constant to be used when the type of a variable needs to be specified.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Number
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var dateVar = solutionModel.newGlobalVariable('globals', 'gDate', JSVariable.DATETIME);
dateVar.defaultValue = 'now';
application.output(scopes.globals.gDate); // Prints the current date and time.
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=INTEGER}{tr:id=name}{td}h6.INTEGER{td}{tr}{tr:id=des}{td}{div:class=sIndent}Constant to be used when the type of a variable needs to be specified.{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Number]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idINTEGER
Table Row (tr)
idname
Table Cell (td)

INTEGER

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Constant to be used when the type of a variable needs to be specified.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Number
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var intVar = solutionModel.newGlobalVariable('globals', 'gInt', JSVariable.INTEGER);
intVar.defaultValue = 997;
application.output(scopes.globals.gInt); // Prints 997
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=MEDIA}{tr:id=name}{td}h6.MEDIA{td}{tr}{tr:id=des}{td}{div:class=sIndent}Constant to be used when the type of a variable needs to be specified.{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Number]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idMEDIA
Table Row (tr)
idname
Table Cell (td)

MEDIA

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Constant to be used when the type of a variable needs to be specified.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Number
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var mediaVar = solutionModel.newGlobalVariable('globals', 'gMedia', JSVariable.MEDIA);
mediaVar.defaultValue = 'new Array(1, 2, 3, 4)';
application.output(scopes.globals.gMedia); // Prints out the array with four elements.
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=NUMBER}{tr:id=name}{td}h6.NUMBER{td}{tr}{tr:id=des}{td}{div:class=sIndent}Constant to be used when the type of a variable needs to be specified.{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Number]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idNUMBER
Table Row (tr)
idname
Table Cell (td)

NUMBER

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Constant to be used when the type of a variable needs to be specified.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Number
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var numberVar = solutionModel.newGlobalVariable('globals', 'gNumber', JSVariable.NUMBER);
numberVar.defaultValue = 192.334;
application.output(scopes.globals.gNumber); // Prints 192.334
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=TEXT}{tr:id=name}{td}h6.TEXT{td}{tr}{tr:id=des}{td}{div:class=sIndent}Constant to be used when the type of a variable needs to be specified.{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Number]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idTEXT
Table Row (tr)
idname
Table Cell (td)

TEXT

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Constant to be used when the type of a variable needs to be specified.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Number
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var txtVar = solutionModel.newGlobalVariable('globals', 'gText', JSVariable.TEXT);
txtVar.defaultValue = '"some text"'; // Use two pairs of quotes if you want to assign a String as default value.
application.output(scopes.globals.gText); // Prints 'some text' (without quotes).
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}\\ {table:id=property|class=servoy sDetail}{colgroup}{column:width=100%|padding=0px}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Property Details{th}{tr}{tbody:id=defaultValue}{tr:id=name}{td}h6.defaultValue{td}{tr}{tr:id=des}{td}{div:class=sIndent}The default value of the variable. It is interpreted as a JS expression. For form variables ,setting this property requires the form instances to be destroyed
Table Row (tr)
classlastDetailRow
Table Cell (td)
 



HTML Table
idproperty
classservoy sDetail
Colgroup Tag
Col
colspan2
width100%
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Property Details
Table Body (tbody)
iddefaultValue
Table Row (tr)
idname
Table Cell (td)

defaultValue

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent

The default value of the variable.

It is interpreted as a JS expression.

For form variables ,setting this property requires the form instances to be destroyed (history.remove("formName")).


If

you

want

to

use

a

default

value

for

a

newly

created

variable

create

the

variable

using

the

3

parameter

version

newVariable(name,type,defaultValue).

For

INTEGER

variables

it

can

be

an

integer

constant,

like

10

for

example.


For

NUMBER

variables

it

can

be

a

real

constant,

like

22.41.

For

DATETIME


variables

it

can

be

"now",

or

a

JS

expression

like

"new

Date()".

For

TEXT


variables

it

can

be

any

string

surrounded

with

quotes,

like

"'some

text'".

{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[String]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}

Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var intVar = solutionModel.newGlobalVariable('globals', 'gInt', JSVariable.INTEGER);
intVar.defaultValue = 997;
application.output(scopes.globals.gInt); // Prints 997
var numberVar = solutionModel.newGlobalVariable('globals', 'gNumber', JSVariable.NUMBER);
numberVar.defaultValue = 192.334;
application.output(scopes.globals.gNumber); // Prints 192.334
var dateVar = solutionModel.newGlobalVariable('globals', 'gDate', JSVariable.DATETIME);
dateVar.defaultValue = 'now';
application.output(scopes.globals.gDate); // Prints the current date and time.
var txtVar = solutionModel.newGlobalVariable('globals', 'gText', JSVariable.TEXT);
txtVar.defaultValue = '"some text"'; // Use two pairs of quotes if you want to assign a String as default value.
application.output(scopes.globals.gText); // Prints 'some text' (without quotes).
var mediaVar = solutionModel.newGlobalVariable('globals', 'gMedia', JSVariable.MEDIA);
mediaVar.defaultValue = 'new Array(1, 2, 3, 4)';
application.output(scopes.globals.gMedia); // Prints out the array with four elements.
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=name}{tr:id=name}{td}h6.name{td}{tr}{tr:id=des}{td}{div:class=sIndent}The name of the variable.{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[String]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idname
Table Row (tr)
idname
Table Cell (td)

name

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
The name of the variable.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var gVar = solutionModel.newGlobalVariable('globals', 'gtext', JSVariable.TEXT);
gVar.name = 'anotherName';
gVar.defaultValue = '"default text"';
// The next two lines will print the same output.
application.output(scopes.globals[gVar.name]);
application.output(scopes.globals.anotherName);
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=variableType}{tr:id=name}{td}h6.variableType{td}{tr}{tr:id=des}{td}{div:class=sIndent}The type of the variable. Can be one of: TEXT, INTEGER, NUMBER, DATETIME or MEDIA.{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[Number]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 
Table Body (tbody)
idvariableType
Table Row (tr)
idname
Table Cell (td)

variableType

Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
The type of the variable. Can be one of: TEXT, INTEGER, NUMBER, DATETIME or MEDIA.
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
Number
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var g = solutionModel.newGlobalVariable('globals', 'gtext',JSVariable.TEXT);
scopes.globals.gtext = 'some text';
g.variableType = JSVariable.DATETIME;
scopes.globals.gtext = 'another text'; // This will raise an error now, because the variable is not longer of type text.
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}\\ {table:id=function|class=servoy sDetail}{colgroup}{column:width=100%|padding=0px}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Method Details{th}{tr}{tbody:id=getScopeName}{tr:id=name}{td}h6.getScopeName{td}{tr}{tr:id=sig}{td}{span:style=margin-right: 5px;}[String]{span}{span:style=font-weight: bold;}getScopeName{span}{span}\(){span}{td}{tr}{tr:id=des}{td}{div:class=sIndent}Get scope name{div}{td}{tr}{tr:id=ret}{td}*Returns*\\{div:class=sIndent}[String]{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
Table Row (tr)
classlastDetailRow
Table Cell (td)
 



HTML Table
idfunction
classservoy sDetail
Colgroup Tag
Col
colspan2
width100%
Col
Table Head (thead)
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Details
Table Body (tbody)
idgetScopeName
Table Row (tr)
idname
Table Cell (td)

getScopeName

Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
String
Span
stylefont-weight: bold;
getScopeName
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Get scope name
Table Row (tr)
idret
Table Cell (td)

Returns

Div
classsIndent
String
Table Row (tr)
idsam
Table Cell (td)

Sample

Div
classsIndent
Code Block
languagejavascript
var globalVariables = solutionModel.getGlobalVariables();
for (var i in globalVariables)
	application.output(globalVariables[i].name + ' is defined in scope ' + globalVariables[i].getScopeName());
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}
Table Row (tr)
classlastDetailRow
Table Cell (td)