JSVariable
Overview
JSVariable
represents script variables in the Solution Model. It allows defining variables with specific types, default values, and scope, offering flexibility for use in forms, global contexts, and dynamic scenarios. Variables can be configured with types like TEXT
, INTEGER
, NUMBER
, DATETIME
, or MEDIA
. ## Functionality
JSVariable provides constants for specifying the variable type. Properties like defaultValue
, name
, and variableType
allow precise control over the variable's configuration. The defaultValue
property can accept expressions such as dates, numbers, or text, enabling dynamic initialization. Methods like getScopeName
and getUUID
facilitate metadata access, such as identifying the variable's scope or its unique identifier.
Examples demonstrate how to create variables dynamically, assign default values, and use them in various scopes. Variables can also be modified to change their type or default behavior.
Variables can alternatively be created and managed using the Variable Editor.
Constants Summarized
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.
Constant to be used when the type of a variable needs to be specified.
Properties Summarized
The default value of the variable.
The name of the variable.
The type of the variable.
Methods Summarized
Get scope name
Returns the UUID of the variable
Constants Detailed
DATETIME
Constant to be used when the type of a variable needs to be specified.
Type Number
Sample
INTEGER
Constant to be used when the type of a variable needs to be specified.
Type Number
Sample
MEDIA
Constant to be used when the type of a variable needs to be specified.
Type Number
Sample
NUMBER
Constant to be used when the type of a variable needs to be specified.
Type Number
Sample
TEXT
Constant to be used when the type of a variable needs to be specified.
Type Number
Sample
Properties Detailed
defaultValue
The default value of the variable.
It is interpreted as a JS expression.
For form variables, setting this property via solutionModel 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'".
Type String
Sample
name
The name of the variable.
Type String
Sample
variableType
The type of the variable. Can be one of: TEXT, INTEGER, NUMBER, DATETIME or MEDIA.
Type Number
Sample
Methods Detailed
getScopeName()
Get scope name
Returns: String
Sample
getUUID()
Returns the UUID of the variable
Returns: UUID
Sample
Last updated