|
Re: Report variables cannot be changed [message #721707 is a reply to message #721507] |
Fri, 02 September 2011 15:59 |
|
This is probably bad naming issue. SetGlobalVariable does not set
report variables but a script global variable. You can get it in an
expression like reportContext.getGlobalVariable. To set a Report
variable ( which were initially intended for pagination variable eg page
n of m for the master page of a report - although they have changed in
scope) use reportContext.setPageVariable . This method works for both
types of report variables.
Jason
On 9/1/2011 7:30 PM, Richard wrote:
> We are trying to derive some control values from report parameters. We thought we could use the global variables in the report context, but these don't appear to be the same as the report variables you declare in the Report Design view. We were having trouble in a fairly complicated report in which we use Java event handlers. As a simple test, we created a simple report (no data and no parameters). The report is attached.
>
> In Eclipse Report Design , we created two report variables: testAlphaVariable and testIntegerVariable. We checked "report variable", not "page variable."
>
> The default for the first was set to "a" and for the second to 1.
>
> On the report layout we show only the two variables with labels.
>
> We simply dragged the variables into the report. The javascript expression for the first variable is: vars["testAlphaVariable"]
>
> A preview showed the two variables with the default values specified.
>
> Then we tried to override the default value of the first variable by setting it with javascript in Initialize:
>
> reportContext.setGlobalVariable("testAlphaVariable", "B");
>
> This, however, had no affect. Preview still showed the default value.
>
> It appears that the report context global variable is not the same as the variable defined to the report. So in what sense are the variables defined to the report variable? How do you change them?
>
> Perhaps we have taken the wrong approach. We want to control what appears in some cell in the report by a using global variable and then testing its value. But that does not work by using vars["variable name"], which always seems to get the default. This is the important question: How do we change the value that appears on the report based on values derived from those that come in as parameters? How do we set up intermediate variables to control what appears?
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.04036 seconds