{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{hidden}
{sub-section:description|text=}{sub-section}\\{table:class=servoy sSummery}{colgroup}{column:width=80px}{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:class=servoy sSummery}{colgroup}{column:width=80px}{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:class=servoy sDetail}{colgroup}{column:width=100%}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Constants Details{th}{tr}{tbody:id=688735FF-ECA0-4C02-87F1-1AE9BE3F8791}{tr:id=name}{td}h6.DATETIME{td}{tr}{tr:id=des}{td}{sub-section:688735FF-ECA0-4C02-87F1-1AE9BE3F8791_des|text=|trigger=button}{sub-section}{sub-section:688735FF-ECA0-4C02-87F1-1AE9BE3F8791_des|trigger=none|class=sIndent}
Cache
index
true
refresh
100d
showRefresh
true
id
doc
title
Refresh page
showDate
true
retry
Enable
servoy sReturnTypes2100%height: 30px;2Supported ClientssWordListSmartClientsWordListWebClientsWordListNGClientsWordListMobileClientservoy sSummary12%30%58%height: 30px;3Constants SummaryConstant to be used when the type of a variable needs to be specified.Constant to be used when the type of a variable needs to be specified.Constant to be used when the type of a variable needs to be specified.Constant to be used when the type of a variable needs to be specified.Constant to be used when the type of a variable needs to be specified.servoy sSummary12%30%58%height: 30px;3Property SummaryThe default value of the variable.The name of the variable.The type of the variable.servoy sSummary12%30%58%height: 30px;3Methods SummaryGet scope nameReturns the UUID of the variableconstantservoy sDetail2100%height:30px2Constants DetailsDATETIMEname
DATETIME
dessIndent
Constant to be used when the type of a variable needs to be specified.
{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:688735FF-ECA0-4C02-87F1-1AE9BE3F8791_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:688735FF-ECA0-4C02-87F1-1AE9BE3F8791_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:688735FF-ECA0-4C02-87F1-1AE9BE3F8791_ret|text=|trigger=button}{sub-section}{sub-section:688735FF-ECA0-4C02-87F1-1AE9BE3F8791_ret|trigger=none|class=sIndent}[Number]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:688735FF-ECA0-4C02-87F1-1AE9BE3F8791_see|text=|trigger=button}{sub-section}{sub-section:688735FF-ECA0-4C02-87F1-1AE9BE3F8791_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:688735FF-ECA0-4C02-87F1-1AE9BE3F8791_see|text=|trigger=button}{sub-section}{sub-section:688735FF-ECA0-4C02-87F1-1AE9BE3F8791_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:688735FF-ECA0-4C02-87F1-1AE9BE3F8791_sam|text=|trigger=button}{sub-section}{sub-section:688735FF-ECA0-4C02-87F1-1AE9BE3F8791_sam|class=sIndent|trigger=none}{code:language=javascript}
var dateVar = solutionModel.newGlobalVariable('gDate', JSVariable.DATETIME);
dateVar.defaultValue = 'now';
application.output(globals.gDate); // Prints the current date and time.
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=A740A060-A4D0-454C-B1F1-7B3BD1A602CD}{tr:id=name}{td}h6.INTEGER{td}{tr}{tr:id=des}{td}{sub-section:A740A060-A4D0-454C-B1F1-7B3BD1A602CD_des|text=|trigger=button}{sub-section}{sub-section:A740A060-A4D0-454C-B1F1-7B3BD1A602CD_des|trigger=none|class=sIndent}ret
Constant to be used when the type of a variable needs to be specified.
{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:D085E4F3-5162-40B3-A684-FCC0CA29C094_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:D085E4F3-5162-40B3-A684-FCC0CA29C094_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:D085E4F3-5162-40B3-A684-FCC0CA29C094_ret|text=|trigger=button}{sub-section}{sub-section:D085E4F3-5162-40B3-A684-FCC0CA29C094_ret|trigger=none|class=sIndent}[Number]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:D085E4F3-5162-40B3-A684-FCC0CA29C094_see|text=|trigger=button}{sub-section}{sub-section:D085E4F3-5162-40B3-A684-FCC0CA29C094_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:D085E4F3-5162-40B3-A684-FCC0CA29C094_see|text=|trigger=button}{sub-section}{sub-section:D085E4F3-5162-40B3-A684-FCC0CA29C094_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:D085E4F3-5162-40B3-A684-FCC0CA29C094_sam|text=|trigger=button}{sub-section}{sub-section:D085E4F3-5162-40B3-A684-FCC0CA29C094_sam|class=sIndent|trigger=none}{code:language=javascript}
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.
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=2F26EBF4-AF2E-46D5-A5CE-0E7C91EAB873}{tr:id=name}{td}h6.NUMBER{td}{tr}{tr:id=des}{td}{sub-section:2F26EBF4-AF2E-46D5-A5CE-0E7C91EAB873_des|text=|trigger=button}{sub-section}{sub-section:2F26EBF4-AF2E-46D5-A5CE-0E7C91EAB873_des|trigger=none|class=sIndent}ret
Constant to be used when the type of a variable needs to be specified.
{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:832DFA05-4907-4F6F-8051-455A63D9AF0E_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:832DFA05-4907-4F6F-8051-455A63D9AF0E_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:832DFA05-4907-4F6F-8051-455A63D9AF0E_ret|text=|trigger=button}{sub-section}{sub-section:832DFA05-4907-4F6F-8051-455A63D9AF0E_ret|trigger=none|class=sIndent}[Number]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:832DFA05-4907-4F6F-8051-455A63D9AF0E_see|text=|trigger=button}{sub-section}{sub-section:832DFA05-4907-4F6F-8051-455A63D9AF0E_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:832DFA05-4907-4F6F-8051-455A63D9AF0E_see|text=|trigger=button}{sub-section}{sub-section:832DFA05-4907-4F6F-8051-455A63D9AF0E_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:832DFA05-4907-4F6F-8051-455A63D9AF0E_sam|text=|trigger=button}{sub-section}{sub-section:832DFA05-4907-4F6F-8051-455A63D9AF0E_sam|class=sIndent|trigger=none}{code:language=javascript}
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).
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}\\{table:class=servoy sDetail}{colgroup}{column:width=100%}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Property Details{th}{tr}{tbody:id=BBAB3FC3-BE10-4FB5-9D38-4EB23EB0DFC3}{tr:id=name}{td}h6.defaultValue{td}{tr}{tr:id=des}{td}{sub-section:BBAB3FC3-BE10-4FB5-9D38-4EB23EB0DFC3_des|text=|trigger=button}{sub-section}{sub-section:BBAB3FC3-BE10-4FB5-9D38-4EB23EB0DFC3_des|trigger=none|class=sIndent}The default value of the variable.
It is interpreted as a JS expressionret
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'
.{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:BBAB3FC3-BE10-4FB5-9D38-4EB23EB0DFC3_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:BBAB3FC3-BE10-4FB5-9D38-4EB23EB0DFC3_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:BBAB3FC3-BE10-4FB5-9D38-4EB23EB0DFC3_ret|text=|trigger=button}{sub-section}{sub-section:BBAB3FC3-BE10-4FB5-9D38-4EB23EB0DFC3_ret|trigger=none|class=sIndent}[String]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:BBAB3FC3-BE10-4FB5-9D38-4EB23EB0DFC3_see|text=|trigger=button}{sub-section}{sub-section:BBAB3FC3-BE10-4FB5-9D38-4EB23EB0DFC3_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:BBAB3FC3-BE10-4FB5-9D38-4EB23EB0DFC3_see|text=|trigger=button}{sub-section}{sub-section:BBAB3FC3-BE10-4FB5-9D38-4EB23EB0DFC3_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:BBAB3FC3-BE10-4FB5-9D38-4EB23EB0DFC3_sam|text=|trigger=button}{sub-section}{sub-section:BBAB3FC3-BE10-4FB5-9D38-4EB23EB0DFC3_sam|class=sIndent|trigger=none}{code:language=javascript}
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.
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=290497CF-62D2-45A0-B675-CB959CED9BFD}{tr:id=name}{td}h6.name{td}{tr}{tr:id=des}{td}{sub-section:290497CF-62D2-45A0-B675-CB959CED9BFD_des|text=|trigger=button}{sub-section}{sub-section:290497CF-62D2-45A0-B675-CB959CED9BFD_des|trigger=none|class=sIndent}
{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:290497CF-62D2-45A0-B675-CB959CED9BFD_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:290497CF-62D2-45A0-B675-CB959CED9BFD_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:290497CF-62D2-45A0-B675-CB959CED9BFD_ret|text=|trigger=button}{sub-section}{sub-section:290497CF-62D2-45A0-B675-CB959CED9BFD_ret|trigger=none|class=sIndent}[String]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:290497CF-62D2-45A0-B675-CB959CED9BFD_see|text=|trigger=button}{sub-section}{sub-section:290497CF-62D2-45A0-B675-CB959CED9BFD_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:290497CF-62D2-45A0-B675-CB959CED9BFD_see|text=|trigger=button}{sub-section}{sub-section:290497CF-62D2-45A0-B675-CB959CED9BFD_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:290497CF-62D2-45A0-B675-CB959CED9BFD_sam|text=|trigger=button}{sub-section}{sub-section:290497CF-62D2-45A0-B675-CB959CED9BFD_sam|class=sIndent|trigger=none}{code:language=javascript}
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);
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=9AC1B5DA-B3E3-414C-A1FA-E7183B7BE3F2}{tr:id=name}{td}h6.variableType{td}{tr}{tr:id=des}{td}{sub-section:9AC1B5DA-B3E3-414C-A1FA-E7183B7BE3F2_des|text=|trigger=button}{sub-section}{sub-section:9AC1B5DA-B3E3-414C-A1FA-E7183B7BE3F2_des|trigger=none|class=sIndent}ret
The type of the variable. Can be one of: TEXT, INTEGER, NUMBER, DATETIME or MEDIA.
{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=prs}{td}*Parameters*\\{sub-section:9AC1B5DA-B3E3-414C-A1FA-E7183B7BE3F2_prs|text=|trigger=button}{sub-section}{div:class=sIndent}{sub-section:9AC1B5DA-B3E3-414C-A1FA-E7183B7BE3F2_prs|trigger=none}{sub-section}{div}{td}{tr}{builder-show}{tr:id=ret}{td}*Returns*\\{sub-section:9AC1B5DA-B3E3-414C-A1FA-E7183B7BE3F2_ret|text=|trigger=button}{sub-section}{sub-section:9AC1B5DA-B3E3-414C-A1FA-E7183B7BE3F2_ret|trigger=none|class=sIndent}[Number]{sub-section}{td}{tr}{builder-show:permission=edit}{tr:id=see}{td}*Also see*\\{sub-section:9AC1B5DA-B3E3-414C-A1FA-E7183B7BE3F2_see|text=|trigger=button}{sub-section}{sub-section:9AC1B5DA-B3E3-414C-A1FA-E7183B7BE3F2_see|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{builder-show:permission=edit}{tr:id=link}{td}*External links*\\{sub-section:9AC1B5DA-B3E3-414C-A1FA-E7183B7BE3F2_see|text=|trigger=button}{sub-section}{sub-section:9AC1B5DA-B3E3-414C-A1FA-E7183B7BE3F2_link|class=sIndent|trigger=none}{sub-section}{td}{tr}{builder-show}{tr:id=sam}{td}*Sample*\\{sub-section:9AC1B5DA-B3E3-414C-A1FA-E7183B7BE3F2_sam|text=|trigger=button}{sub-section}{sub-section:9AC1B5DA-B3E3-414C-A1FA-E7183B7BE3F2_sam|class=sIndent|trigger=none}{code:language=javascript}
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.
{code}{sub-section}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}ret