Child pages
  • JSVariable

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

padding0px
width80px

...

Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan2
Constants Summary

...

Table Cell (td)
Number

...

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 'class' inside the {div} macro with 'id=description'
Divcache
styleindexdisplay:none

...

iddescription

...

true
refresh100d
showRefreshtrue
iddoc
titleRefresh page
showDatetrue
retryEnable

servoy sReturnTypes2100%height: 30px;2Supported ClientssWordListSmartClientsWordListWebClientsWordListNGClientsWordListMobileClient

servoy sSummary12%30%58%height: 30px;3Constants SummaryConstant to be used when the type of a variable needs to be specified.

...

Table Cell (td)
Number

...

...

Constant to be used when the type of a variable needs to be specified.

...

Table Cell (td)
Number

...

...

Constant to be used when the type of a variable needs to be specified.

...

Table Cell (td)
Number

...

...

Constant to be used when the type of a variable needs to be specified.

...

Table Cell (td)
Number

...

...

padding0px
width80px

...

Constant to be used when the type of a variable needs to be specified.

...

...

servoy sSummary12%30%58%height: 30px;

...

Table Head (th)
colspan2
Property Summary

...

Table Cell (td)
String
3Property SummaryThe default value of the variable.

...

Table Cell (td)
String

...

...

Table Cell (td)
Number

...

The name of the variable.

...

The type of the variable.

...

servoy sSummary

...

padding0px
width80px

...

Table Cell (td)
UUID

...

12%30%58%height: 30px;

...

Table Head (th)
colspan2
Method Summary
Table Row (tr)
Table Cell (td)
String
Table Cell (td)
getScopeName()
Get scope name

...

3Methods SummaryGet scope nameReturns the UUID of the variable

...

...

constant

...

servoy sDetail

...

padding0px
width100%

...

2100%height:30px

...

colspan1

...

2Constants Details

...

DATETIME

...

name

...

DATETIME

...

des

...

sIndent
Constant to be used when the type of a variable needs to be specified.

...

ret

...

Returns

...

classlastDetailRow

...

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
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 sIndentclients

...

classsIndent

...

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.

...

classlastDetailRow

...

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

...

classlastDetailRow

...

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.

...

classlastDetailRow

...

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

...

classlastDetailRow

...

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).
Table Row (tr)
idname
Table Cell (td)
getUUID
Table Row (tr)
idsig
Table Cell (td)
Span
stylemargin-right: 5px;
UUID
Span
stylefont-weight: bold;
getUUID
Span
()
Table Row (tr)
iddes
Table Cell (td)
Div
classsIndent
Returns the UUID of the variable
Table Row (tr)
idret
Table Cell (td)
Returns
Div
classsIndent
UUID
Table Row (tr)
idsam
Table Cell (td)
Sample
Div
classsIndent
Code Block
languagejavascript
var dateVar = solutionModel.newGlobalVariable('globals', 'gDate', JSVariable.DATETIME);
application.output(dateVar.getUUID().toString());

...

classlastDetailRow

...


variables it can be any string surrounded with quotes, like "'some text'".
rettd

Returns


div

sIndent

Supported Clients

sIndentSmartClient,WebClient,NGClient,MobileClient
sam

Sample

sIdentjavascript
lastDetailRow
INTEGERname

INTEGER

dessIndent
Constant to be used when the type of a variable needs to be specified.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient,MobileClient
sam

Sample

sIdentjavascript
lastDetailRow
MEDIAname

MEDIA

dessIndent
Constant to be used when the type of a variable needs to be specified.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient,MobileClient
sam

Sample

sIdentjavascript
lastDetailRow
NUMBERname

NUMBER

dessIndent
Constant to be used when the type of a variable needs to be specified.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient,MobileClient
sam

Sample

sIdentjavascript
lastDetailRow
TEXTname

TEXT

dessIndent
Constant to be used when the type of a variable needs to be specified.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient,MobileClient
sam

Sample

sIdentjavascript
lastDetailRow

propertyservoy sDetail2100%height:30px2Property DetailsdefaultValuename

defaultValue

dessIndent
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

id
Table Row (tr)
class
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.
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);
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.
Table Row (tr)
classlastDetailRow
Table Cell (td)

...

idfunction
classservoy sDetail

...

padding0px
width100%
Table Row (tr)
styleheight: 30px;
Table Head (th)
colspan1
Method Details

...

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());

...

classlastDetailRow

...

idgetUUID
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient,MobileClient
sam

Sample

sIdentjavascript
lastDetailRow
namename

name

dessIndent
The name of the variable.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient,MobileClient
sam

Sample

sIdentjavascript
lastDetailRow
variableTypename

variableType

dessIndent
The type of the variable. Can be one of: TEXT, INTEGER, NUMBER, DATETIME or MEDIA.
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient,MobileClient
sam

Sample

sIdentjavascript
lastDetailRow

functionservoy sDetail2100%height:30px2Methods DetailsgetScopeNamename

getScopeName()

dessIndent
Get scope name
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient,MobileClient
sam

Sample

sIdentjavascript
lastDetailRowgetUUIDname

getUUID()

dessIndent
Returns the UUID of the variable
ret

Returns

sIndent
clients

Supported Clients

sIndentSmartClient,WebClient,NGClient,MobileClient
sam

Sample

sIdentjavascript
lastDetailRow