...
This page has advanced features that require a knowledge of JavaScript. The scripting is done in the Script window accessed through the Edit Script button of the Report Template Update page.
Details
In expressions (created by using Expression dialog or using <%= %> syntax in the template) the following short-hand is allowed to reference variable values:
<%= #code %> - results in the variable's value or blank if the value is null.
<%= #code1 + #code2 %> - if the values are numeric, will result in the two numbers being added together, otherwise the two values will be concatenated together.
In expressions, script, or script blocks
Variable Type | Missing value treated as null or Variables without a missing value definition | Missing value displayed |
---|---|---|
Numeric | #code.displayValue.value | #code.value.value |
Numeric calculation | #code.displayValue.value | |
Categorical value (e.g. 0, 1) (radio button or picklist) | #code.displayValue.value | #code.value.value |
Categorical name (eg. no, yes) (radio button or picklist) | #code.displayValue.name | #code.value.name |
Date | To display a date: #code.displayValue.toString() To use a date in a calculation: #code.value.value | |
Text / memo | #code.displayValue.toString() | |
Checkbox | #code.value.value |
#code.displayValue.toString() displays:
- The variable's value, or
- Blank if the value is null or defined as a missing value
#code.value.toString() displays:
- the variable's value (even if the value is defined as missing) or
- blank if the value is null.
#code.displayValue.value displays:
- Numeric variables: returns a number
- Date variables: returns a date
- All other variables: returns a string representation of the value
- Missing values or null: returns null
...
#code.value.value displays:
- Numeric variables: returns a number
- Date variables: returns a date
- All other variables: returns a string representation of the value
- Missing values: returns the missing value
- Null: returns null
#code.value.value - if the value is for a numeric variable, the result is a number; if the value is for a date variable, the result is a date; otherwise the result is a string representation of the value. If the value is null, the result is null. Note, values defined as missing are returned (i.e., they are not returned as null).
#code#code.displayValue.name - returns the picklist display name associated with the variable's value. If the value is null or defined as a missing value, empty string is returned.#
code#code.value.name - returns the picklist display name associated with the variable's value even if the value is defined as missing. If the value is null, empty string is returned.
Detailed explanation
#code - refers to an object with the following properties: variableId, definition, displayValue, value.
...
d) toString(): returns a string representation of the value or empty string.
Examples
Output a variable value:
<% Output.Write( #code.displayValue.toString() );
Output a variable value even if it is defined as missing:
<% Output.Write( #code.value.toString() );
Output a sum of two numeric variables:
...