Expressions
Expressions make up the bulk of the Scripting used in BIRT. In fact, we have used
Expressions multiple times already in this book. Expressions are usually single line
statements that return a single result. Tasks such as retrieving a value from a row
and outputting it in a Data element, retrieving parameter values, and the Highlight
Expressions used in the last chapter are all examples of Expressions. Any time we
use the Expression Editor in BIRT, we are working with Expressions.
In the last chapter, we used a few Expressions to format Date types to YYYY-MM
format. Let's look at these again and understand what they are doing. Following is
the first Expression we used to format the dates:
var combinedDate = row["ORDERDATE"].getFullYear() + "-";
if ((row["ORDERDATE"].getMonth() + 1) < 10)
{
combinedDate += "0" + (row["ORDERDATE"].getMonth() + 1);
}
else
{
combinedDate += (row["ORDERDATE"].getMonth() + 1);
}
combinedDate;
???
?° ?° ?°
??? ???
?° ?°
Chapter 10
[ 237 ]
In the line
var combinedDate = row["ORDERDATE"].getFullYear() + "-";
we are creating a new variable called combinedDate. In BIRT Script, you do not
need to set the variable type of a variable; BIRT will take care of this for you.
row["ORDERDATE"] is a means of accessing the value of the column ORDERDATE
using array index notation.
Pages:
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188