Hi, <br />
<br />
I am trying to perform some aggregate calculations on a data set based on a field value that is grouped on in a simple table. I want the aggregate calculations to be performed for each grouping, but against the entire data set, and not just the data within each group. The way I thought to do this was to assign a persistent global variable via script using 'reportContext'. <br />
<br />
Reading the <a class='bbc_url' href='
http://www.eclipse.org/birt/phoenix/deploy/reportScripting.php'>documentation</a> on report scripting, and also referring to this <a class='bbc_url' href='
http://www.scribd.com/doc/2685017/BIRT-Advanced-Scripting-EclipseCon-2008'>this</a> powerpoint from EclipseCon that has some useful info on event triggering order for writing event handlers in javascript, I would expect to be able to do the following:<br />
<br />
1. Set the persistent global variable in the 'onCreate' event for the Table Group as follows:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>reportContext.setPersistentGlobalVariable("globalVar",this.getRowData().getColumnValue('groupedDateField'))</pre>
<br />
2. Retrieve the global variable in my aggregation calculation to use in the Filter Condition expression for an aggregation that I placed in the group footer. In 'Filter Condition', I do a check of the following:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>reportContext.getPersistentGlobalVariable("globalVar") != null</pre>
<br />
However 'globalVar' always shows up as null in the filter condition, and I can't use it to filter the data set rows on which I'd like the aggregation to process.<br />
<br />
I also did some testing/debugging to figure out what was going on where I tried to set the global variable in the 'onCreate' event handler of a regular detail row of my table (ie not the Table Group 'onCreate' event) via the same code as above, and then display the value of the global variable in a data element in a cell in the same detail row via the same expression used in my filter:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>reportContext.getPersistentGlobalVariable("globalVar");</pre> <br />
<br />
What happens in this case is that on the first detail row in my table the expression evaluates to null and the cell is blank, but in the second row, the cell does in fact display the value of 'globalVar', however it is assigned to the value of the 'groupedDateField' from the previous row in the data set.<br />
<br />
So, it looks like the order the 'onCreate' events are fired means that you can't access row data to set a global variable and then display the value of the variable within the same row? There appears to be a one row delay where the variable is set after the row is read and displayed. The documentation seemed to indicate otherwise from what I could tell, but event order firing is sort of a confusing concept to understand and the documentation isn't very thorough in explaining it (at least the documentation I've found so far).<br />
<br />
Any suggestions for how to do this or whether or not the behavior I'm seeing is correct would be very much appreciated! <br />
<br />
Thank you.