Hi,
I have to dynamically insert a footer in master page based on a particular column in dataset.
I followed the link -
http://www.birt-exchange.org/org/devshare/designing-birt-reports/1294-dataset-table-data-in-masterpage-header/
In my case, i used the below script
1)initialize()
reportContext.setPersistentGlobalVariable("htmlTable","");
2)onFetch() of the dataset
if (htmlTable== ""){
htmlTable = row["aggr"]; (Values-Y/N)
}
else{
htmlTable = row["aggr"];
}
where aggr is something like (SELECT decode(count(*), 0, 'N', 'Y') FROM CUSTOMERS WHERE CITY = 'NYC')
3)Then, the visibility of the footer label is hidden based on the below value
reportContext.getPersistentGlobalVariable("htmlTable")!="Y"
BUt i get the below error
Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot find default value for object. (DataSet[DataSet1].__bm_onFetch#2)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3240)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3230)
at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3246)
at org.mozilla.javascript.ScriptRuntime.typeError1(ScriptRuntime.java:3258)
at org.mozilla.javascript.ScriptableObject.getDefaultValue(ScriptableObject.java:599)
at org.mozilla.javascript.ScriptRuntime.toPrimitive(ScriptRuntime.java:2442)
at org.mozilla.javascript.ScriptRuntime.eqString(ScriptRuntime.java:2572)
at org.mozilla.javascript.ScriptRuntime.eq(ScriptRuntime.java:2516)
at org.mozilla.javascript.gen.c318._c1(DataSet[DataSet1].__bm_onFetch:2)
at org.mozilla.javascript.gen.c318.call(DataSet[DataSet1].__bm_onFetch)
at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:105)
at org.mozilla.javascript.gen.c17._c0(DataSet[Data Set].__bm_onFetch:1)
at org.mozilla.javascript.gen.c17.call(DataSet[Data Set].__bm_onFetch)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:304)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2769)
at org.mozilla.javascript.gen.c17.call(DataSet[Data Set].__bm_onFetch)
at org.mozilla.javascript.gen.c17.exec(DataSet[Data Set].__bm_onFetch)
at org.eclipse.birt.core.script.JavascriptEvalUtil.evaluateRawScript(JavascriptEvalUtil.java:95)
... 121 more
I also tried the same with a sample report(find attached)(Note : in the sample report , i have used simply 'CUSTOMERNUMBER' for determining the visibility,since decode() cannot be used in the dataset)