...
Expressions are a means to of dynamically calculate calculating values for variables. Consider Note that the names of variables are case-sensitive.
ExampleExamples:
true
1
"'some string"'
$variable
$returnCode <= 3
$number + 1
...
The following constant values are supported: true,
false
ExampleExamples:
Expression | true |
---|
JSON | "var": true |
---|
Expression | false |
---|
JSON | "var": false |
---|
...
Strings are written in double quotes. The control characters \t
(tab), \r
(CR) and \n
(NL) are literally written. To suppress its special meaning the $
character is written \$
. No other characters are allowed to follow the \ escape character.
ExampleExamples:
Expression | some value
|
---|
JSON | "var": "some value" | some value" |
---|
Explanation | Unquoted values that are added to the JOC Cockpit GUI are considered strings if they do not start with a digit, a Boolean value or the name of a built-in function. |
---|
Expression | 'some value'
|
---|
JSON | "var": " |
---|
\"\""'" |
Explanation | Single quoted values are considered string constants. |
---|
Expression | "\t means the TAB control character"
|
---|
JSON | "var": "\"\\t means the TAB control character\"" |
---|
Explanation | Double quoted values can hold special special characters and variables. Inside double quotes backslashes are automatically doubled with the JSON storage format. |
---|
Expression | "\r means the CR control character"
|
---|
JSON | "var": "\"\\r means the CR control character\""
|
---|
...
Expression | "\$ means the literal character"
|
---|
JSON | "var": "\"\\$ means the literal character\"" |
---|
Explanation | A backslash can be used to escape the $ character that otherwise signals a variable. |
---|
Number
Numeric constants are implemented as Java BigDecimal
values and allow integer values and long values to be specified.
Example:
Expression | 1
|
---|
JSON | "var": 1 |
---|
Explanation | Numeric values that are assigned without use of quoting are considered being numbers. |
---|
Expression | '05331'
|
---|
JSON | "var": "'05331'" |
---|
Explanation | Numeric values that are assigned with single quotes are considered being strings and for exapmle preserve leading zeros. |
---|
Operators
Comparison Operators
...
The result of a comparison is the Boolean
data type. Comparisons are available for strings and numbers. Both sides of a comparison have to use the same data type.
Should this rule not be considered observed and should e.g. , for example, a number be compared to with a string then an the Order will fail.
Example:
Expression | $var >= 199
|
---|
JSON | "varisGreater": "$var >= 199" |
---|
Arithmetic Operators
Addition and Subtraction of two numbers with: +, -
ExampleExamples:
Expression | 1 + 1
|
---|
JSON | "var": 1 + 1 |
---|
...
Expression | "abc" ++ "def"
|
---|
JSON | "var": "\"abc\" ++ \"def\"" |
---|
Logical Operators
Evaluate a Boolean expression and if the result is false
then an alternative value is returned.
Example:
Expression | false orElse true
|
---|
JSON | "var": "false orElse true" |
---|
Conversion
Convert to Number
If a the value of a variable with of the String data type represents a number then it can be converted. Otherwise an error is raised and the affected order Order fails.
Example:
Expression | "123".toNumber
|
---|
JSON | "var": "\"123\".toNumber" |
---|
...
Referencing Variables
The syntax $VARIABLE
, $`VARIABLE`,
${VARIABLE}
or ${`VARIABLE`}
is used to read the value of a variable.
- Similar to a number of Unix shells, a variable can be recalled with $ or with ${}.
...
- Variable names can include dots, however, not at the beginning and not at the end of the variable name and not as a sequence of dots.
- Variable names with dots have to be referenced like this:
$`mail.smtp.host`
or ${`mail.smtp.host`}
If the variable is unknown then an error is raised and the affected Order will fail.
...
Variables can be retrieved using the function function:
variable( NAMEstring: <variable>, label=LABEL<label>, job=JOB<job>, default=DEFAULT <default> )
NAME
<variable>
is a string expression for the name of the variable.label=LABEL<label>
(optional) is the label of an instruction for which the variable is recalled. Consider Note that the label is not quoted. Example: label=A
.job=JOB<job>
(optional) is the name of a job for which the variable is recalled. Consider Note that the job name is not quoted. ExampleFor example: job=MYJOB
.- label and job cannot be specified at the same time
default=DEFAULT<default>
(optional) specifies a the default value should if the variable does not exist.
Consider Note that a call to the variable
function will fail if the variable is unknown and no a default value is specifiedhas not been specified. This function cannot be used within a Job Resource.
ExampleExamples:
Expression | variable( "my_var", job=my_job )
|
---|
JSON |
---|
"\ \\\\\"" |
Comment | The value of the variable my_var is returned as available with the job my_job in a workflow. If the variable is unknown then the function fails. |
---|
Expression | variable( "my_var", label=my_label, default="some value" )
|
---|
JSON |
---|
"\ \\\\", label=my_label, default= |
\\\\\" |
Comment | The value of the variable my_var is returned as available with the job identified by the label my_label in a workflow. If the variable is unknown then the default value some value is returned. |
---|
Built-in Variables
Built-in variables are available at the following scopes:
...
$js7WorkflowPath
- The unique name of a workflow. Consider Note that the name does not include the workflow folder location of a workflow.
$js7WorkflowPosition
- The position of an order in the workflow.
$js7Label
- The label of the current instruction for which an order is executed.
$js7OrderId
$js7ControllerId
- The Controller's identifier as specified on installation.
Job
$js7JobName
- The name of the current job for which an order is executed..
$js7JobExecutionCount
- A counter for the number of times that the same job node is executed within a workflow, for example, if used with the JS7 - Retry Instruction.
$js7EpochMilli
$epochMilli
- The number of milliseconds since January 1st 1970 UTC.
$returnCode
- The numeric exit code of the current job for which an order is executed.
Build-in Functions
Built-in Functions
env( string: <environment-variable>, string: <default> )
nownow( format='yyyy-MM-dd hh:mm:ss', timezone='Europe/Berlin' )
- The job start date. This date can be formatted using Java date qualifiers. Optionally a time zone can be specified, by default the UTC time zone is used.
ExampleExamples:
Expression | now( format='yyyy-MM-dd' )
|
---|
JSON | " |
---|
\"now( format='yyyy-MM-dd' ) |
\"Expression | now( format='yyyy-MM-dd hh:mm:ss' )
|
---|
JSON | " |
---|
\"now( format='yyyy-MM-dd hh:mm:ss' ) |
\"" |
Sample Value | 2021-05-03 07:30:42 |
---|
Expression | now( format='yyyy-MM-dd hh:mm:
|
---|
ssUTC"\"now( format='yyyy-MM-dd hh:mm: |
ss\\\\\"" |
Sample Value | 2021-05-03 09:30:42+02:00 |
---|
Anchor |
---|
| function_scheduledorempty |
---|
| function_scheduledorempty |
---|
|
scheduledOrEmpty( format='yyyy-MM-dd hh:mm:ss', timezone='Europe/Berlin' )
- The date for which an orders is order has been scheduled.
- The date formatting options are the same as described with the
now()
function.
Anchor |
---|
| function_replaceall |
---|
| function_replaceall |
---|
|
replaceAll( string: String, regex: String, replacement: String)
Anchor |
---|
| function_jobresourcevariable |
---|
| function_jobresourcevariable |
---|
|
jobResourceVariable( string: <JobResource>, string: <Variable> )
JobResource:<JobResource>:<Variable>
Anchor |
---|
| function_tofile |
---|
| function_tofile |
---|
|
toFile( string: <Content>, string: <FileSpecification>
- The function returns the absolute path to a temporary file which holds the value of the specified
<Content>
. This can be a constant string or a variable of type string. - The file path is determined by the Agent using its
JS7_AGENT_DATA/work/values
directory and a temporary sub-directory. - The
<FileSpecification>
is used to determine the file extension, for example *.xml. - The function can only be used with JS7 - Job Resources and JS7 - Jobs.
- Typical use cases include a situation when longer values for job resource variables or order variables are used and where these would be truncated when exposed as environment variables in shell jobs. In this situation the variable's value can be written to a temporary file and the job's environment variables receives the path to the temporary file. This can then be processed using, for example, OS commands.
Examples:
Expression | toFile( 'some long string value', '*.txt' )
|
---|
JSON | "toFile( 'some long string value', '*.txt' )" |
---|
Sample Value | /home/sos/agent/var_4445/work/values/0/32.txt |
---|
Further Resources