Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Global Variable not accessible in CrossTab
Bharath406
Hi,
I have a variable defined in beforeOpen() of one of the datasets. But when I try to access this report in CrossTab it is throwing an error saying the variable is not defined. The same variable is working fine on the charts.
Any clue? BTW, I'm using BIRT 2.3.2.2
Find more posts tagged with
Comments
mwilliams
Hi Bharath406,
What is your code in the beforeOpen and in the crosstab? What are you trying to do with the global variable? Let me know.
Bharath406
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="68811" data-time="1285597949" data-date="27 September 2010 - 07:32 AM"><p>
Hi Bharath406,<br />
<br />
What is your code in the beforeOpen and in the crosstab? What are you trying to do with the global variable? Let me know.<br /></p></blockquote>
<br />
Ok. A long explanation. I have a primary data set, in which a column retrieves a custom attribute in the form of literal id. In order to map this literal id to its value, I need to use another data set(This is the data set I was talking about in my first post). Here is the beforeOpen() and onFetch() code for this dataset.<br />
<br />
beforeOpen() { deferredFrom = new Object();}<br />
onFetch() {deferredFrom[row["LITERAL_ID"]] = row["LITERAL_NAME"];}<br />
<br />
And now, in the primary dataset I use a computed column with the expression <br />
deferredFrom[row["STRING_VAL"]];<br />
<br />
where row["STRING_VAL"] is nothing but the id of the custom attribute.<br />
<br />
Finally, for crosstab I use data from the primary data set (although I don't use this computed column)<br />
<br />
And the error comes up saying deferredFrom is not defined.<br />
<br />
Attaching the design file.
Bharath406
somehow I'm unable attach the file.
mwilliams
Can you email it to me? mwilliams@birt-exchange.com
In this same report, this setup works in a chart? Or is that in a different report? If it's not in this report, do you have a report element that is tied to the dataSet with the script in it in the report, before the crosstab?
Bharath406
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="68820" data-time="1285612084" data-date="27 September 2010 - 11:28 AM"><p>
Can you email it to me? mwilliams@birt-exchange.com<br />
<br />
In this same report, this setup works in a chart? Or is that in a different report? If it's not in this report, do you have a report element that is tied to the dataSet with the script in it in the report, before the crosstab?<br /></p></blockquote>
Yes Michael, the same report has a chart and it works fine. I use the same dataset both for the chart and the crosstab.
mwilliams
Sorry, I meant, is your non-primary dataSet where you're setting the value of your object attached to a report element prior to the crosstab and chart? Did you send your report to my email? I have not looked yet if you have.
mwilliams
I did get your email, but it did not allow me to open the file. It gave me an error and then opened a blank "XML Source" page. Not sure what's going on there.
Bharath406
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="68828" data-time="1285618807" data-date="27 September 2010 - 01:20 PM"><p>
Sorry, I meant, is your non-primary dataSet where you're setting the value of your object attached to a report element prior to the crosstab and chart? Did you send your report to my email? I have not looked yet if you have.<br /></p></blockquote>
<br />
well I dint completely understand your question, but at the top of the report page I add a hidden dynamic text box with expression Total.count(); and bind it to the non-primary dataset. This is done prior to the chart and crosstab
mwilliams
Bharath,
Our best bet might be if you can recreate this issue with the sample database so that I can see what's going on. Let me know if you aren't able to.
Bharath406
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="68849" data-time="1285687258" data-date="28 September 2010 - 08:20 AM"><p>
Bharath,<br />
<br />
Our best bet might be if you can recreate this issue with the sample database so that I can see what's going on. Let me know if you aren't able to.<br /></p></blockquote>
Yup. I'm able to recreate the error using sample DB. The object(officePhone) is defined in Data Set1 as below:<br />
<br />
beforeOpen(){officePhone = new Object();}<br />
onFetch(){officePhone[row["OFFICECODE"]] = row["PHONE"];}<br />
<br />
And in Data Set, I create a computed column with expression : officePhone[row["OFFICECODE"]];<br />
<br />
In the report, I use a hidden dynamic text, with an expression Total.count(); and bind it to Data Set1.<br />
<br />
Now, the table doesn't throw any error. But when I use a crosstab, it says officePhone is not defined.<br />
<br />
Attached is the design file.<br />
<br />
-- Bharath
mwilliams
Bharath,
If I initialize the object in the initialize method like is done in the beforeOpen method, too, it works with no error.
officePhone = new Object(); //put in initialize method as well.
Not sure why this happens, but it seems to solve it.
Bharath406
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="68855" data-time="1285701684" data-date="28 September 2010 - 12:21 PM"><p>
Bharath,<br />
<br />
If I initialize the object in the initialize method like is done in the beforeOpen method, too, it works with no error.<br />
<br />
officePhone = new Object(); //put in initialize method as well.<br />
<br />
Not sure why this happens, but it seems to solve it.<br /></p></blockquote>
<br />
Yup. That solved the issue. So is it that CrossTabs handle global variables differently?
mwilliams
I'm not sure on the reason behind this. That just happened to be the first thing I though of to try. You could always put in a bug report for it not recognizing the object in a crosstab and see what they say.
Bharath406
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="68857" data-time="1285704041" data-date="28 September 2010 - 01:00 PM"><p>
I'm not sure on the reason behind this. That just happened to be the first thing I though of to try. You could always put in a bug report for it not recognizing the object in a crosstab and see what they say.<br /></p></blockquote>
<br />
Hmmm... I have a different issue on my actual report now. If I have the object declared in initialize method, though I dont see the error I dont see the crosstab as well
mwilliams
I'm not sure what would be happening here, especially with not being able to see your report. This didn't happen in the sample database example did it? It didn't for me. Are you able to upgrade your BIRT version? If so, could you try your report in a newer version of BIRT?
Bharath406
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="68885" data-time="1285773589" data-date="29 September 2010 - 08:19 AM"><p>
I'm not sure what would be happening here, especially with not being able to see your report. This didn't happen in the sample database example did it? It didn't for me. Are you able to upgrade your BIRT version? If so, could you try your report in a newer version of BIRT?<br /></p></blockquote>
Yes, the solution works fine with sample database. My actual report points to RTC database. That may be the reason you are unable to open it.<br />
Will upgrade the BIRT Version and check that.<br />
<br />
Thanks