Child pages
  • JSVariable

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Hidden
DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY, UNLESS YOU KNOW WHAT YOU'RE DOING.
		THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO EXTRACT CHANGES FROM THE PAGE AND MERGE THEM BACK INTO SERVOY SOURCE


HTML Table
classservoy sSummary
Colgroup Tag
Column
padding0px
width80px

Column

Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Constants Summary
Table Body (tbody)
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 Body (tbody)
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 Body (tbody)
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 Body (tbody)
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 Body (tbody)
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
classservoy sSummary
Colgroup Tag
Column
padding0px
width80px

Column

Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Property Summary
Table Body (tbody)
Table Row (tr)
Table Cell (td)
String
Table Cell (td)
#defaultValue
The default value of the variable.
Table Body (tbody)
Table Row (tr)
Table Cell (td)
String
Table Cell (td)
#name
The name of the variable.
Table Body (tbody)
Table Row (tr)
Table Cell (td)
Number
Table Cell (td)
#variableType
The type of the variable.

HTML Table
classservoy sSummary
Colgroup Tag
Column
padding0px
width80px

Column

Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Method Summary
Table Body (tbody)
Table Row (tr)
Table Cell (td)
UUID
Table Cell (td)
#getUUID()
Returns the UUID of the variable

HTML Table
idconstant
classservoy sDetail
Colgroup Tag
Column
padding0px
width100%

Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan1
Constants Details
Table Body (tbody)
idDATETIME
classnode
Table Row (tr)
idname
Table Cell (td)
DATETIME
Table Row (tr)
iddes
Table Cell (td)
Constant to be used when the type of a variable needs to be specified.
Table Row (tr)
idret
Table Cell (td)
Returns
Number
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
var dateVar = solutionModel.newGlobalVariable('gDate', JSVariable.DATETIME);
dateVar.defaultValue = 'now';
application.output(globals.gDate); // Prints the current date and time.
Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idINTEGER
classnode
Table Row (tr)
idname
Table Cell (td)
INTEGER
Table Row (tr)
iddes
Table Cell (td)
Constant to be used when the type of a variable needs to be specified.
Table Row (tr)
idret
Table Cell (td)
Returns
Number
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
var intVar = solutionModel.newGlobalVariable('gInt', JSVariable.INTEGER);
intVar.defaultValue = 997;
application.output(globals.gInt); // Prints 997
Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idMEDIA
classnode
Table Row (tr)
idname
Table Cell (td)
MEDIA
Table Row (tr)
iddes
Table Cell (td)
Constant to be used when the type of a variable needs to be specified.
Table Row (tr)
idret
Table Cell (td)
Returns
Number
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
var mediaVar = solutionModel.newGlobalVariable('gMedia', JSVariable.MEDIA);
mediaVar.defaultValue = 'new Array(1, 2, 3, 4)';
application.output(globals.gMedia); // Prints out the array with four elements.
Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idNUMBER
classnode
Table Row (tr)
idname
Table Cell (td)
NUMBER
Table Row (tr)
iddes
Table Cell (td)
Constant to be used when the type of a variable needs to be specified.
Table Row (tr)
idret
Table Cell (td)
Returns
Number
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
var numberVar = solutionModel.newGlobalVariable('gNumber', JSVariable.NUMBER);
numberVar.defaultValue = 192.334;
application.output(globals.gNumber); // Prints 192.334
Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idTEXT
classnode
Table Row (tr)
idname
Table Cell (td)
TEXT
Table Row (tr)
iddes
Table Cell (td)
Constant to be used when the type of a variable needs to be specified.
Table Row (tr)
idret
Table Cell (td)
Returns
Number
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
var txtVar = solutionModel.newGlobalVariable('gText', JSVariable.TEXT);
txtVar.defaultValue = '"some text"'; // Use two pairs of quotes if you want to assing a String as default value.
application.output(globals.gText); // Prints 'some text' (without quotes).
Table Row (tr)
classlastDetailRow
Table Cell (td)


HTML Table
idproperty
classservoy sDetail
Colgroup Tag
Column
padding0px
width100%

Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan1
Property Details
Table Body (tbody)
iddefaultValue
classnode
Table Row (tr)
idname
Table Cell (td)
defaultValue
Table Row (tr)
iddes
Table Cell (td)

The default value of the variable.

It is interpreted as a JS expression.

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'.

Table Row (tr)
idret
Table Cell (td)
Returns
String
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
var intVar = solutionModel.newGlobalVariable('gInt', JSVariable.INTEGER);
intVar.defaultValue = 997;
application.output(globals.gInt); // Prints 997
var numberVar = solutionModel.newGlobalVariable('gNumber', JSVariable.NUMBER);
numberVar.defaultValue = 192.334;
application.output(globals.gNumber); // Prints 192.334
var dateVar = solutionModel.newGlobalVariable('gDate', JSVariable.DATETIME);
dateVar.defaultValue = 'now';
application.output(globals.gDate); // Prints the current date and time.
var txtVar = solutionModel.newGlobalVariable('gText', JSVariable.TEXT);
txtVar.defaultValue = '"some text"'; // Use two pairs of quotes if you want to assing a String as default value.
application.output(globals.gText); // Prints 'some text' (without quotes).
var mediaVar = solutionModel.newGlobalVariable('gMedia', JSVariable.MEDIA);
mediaVar.defaultValue = 'new Array(1, 2, 3, 4)';
application.output(globals.gMedia); // Prints out the array with four elements.
Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idname
classnode
Table Row (tr)
idname
Table Cell (td)
name
Table Row (tr)
iddes
Table Cell (td)
The name of the variable.
Table Row (tr)
idret
Table Cell (td)
Returns
String
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
var gVar = solutionModel.newGlobalVariable('gtext', JSVariable.TEXT);
gVar.name = 'anotherName';
gVar.defaultValue = '"default text"';
// The next two lines will print the same output.
application.output(globals[gVar.name]);
application.output(globals.anotherName);
Table Row (tr)
classlastDetailRow
Table Cell (td)

Table Body (tbody)
idvariableType
classnode
Table Row (tr)
idname
Table Cell (td)
variableType
Table Row (tr)
iddes
Table Cell (td)
The type of the variable. Can be one of: TEXT, INTEGER, NUMBER, DATETIME or MEDIA.
Table Row (tr)
idret
Table Cell (td)
Returns
Number
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
var g = solutionModel.newGlobalVariable('gtext',JSVariable.TEXT);
globals.gtext = 'some text';
g.variableType = JSVariable.DATETIME;
globals.gtext = 'another text'; // This will raise an error now, because the variable is not longer of type text.
Table Row (tr)
classlastDetailRow
Table Cell (td)


HTML Table
idfunction
classservoy sDetail
Colgroup Tag
Column
padding0px
width100%

Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan1
Method Details
Table Body (tbody)
idgetUUID
classnode
Table Row (tr)
idname
Table Cell (td)
getUUID
Table Row (tr)
idsig
Table Cell (td)
Span
stylefloat: left; margin-right: 5px;
UUID
Span
stylefloat: left; font-weight: bold;
idiets
getUUID
Span
stylefloat: left;
idiets
()
Table Row (tr)
iddes
Table Cell (td)
Returns the UUID of the variable
Table Row (tr)
idret
Table Cell (td)
Returns
UUID
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
var dateVar = solutionModel.newGlobalVariable('gDate', JSVariable.DATETIME);
application.output(dateVar.getUUID().toString());
Table Row (tr)
classlastDetailRow
Table Cell (td)