Community
Participate
Working Groups
Resource scripts assigned to report via Report - Resources - Javascript files cannot be directly used in chart scripts. Calling any of the the resource scripts generates ReferenceError when report is previewed.
This issue is happening also in the following context: a) Define an external file as javascript resource in a library (rptlibrary). b) You will see that you can use the functions defined in your external file everywhere in the library (report items, master pages, etc). c) Now create a report design file (rtpdesign) and include you rptlibrary in that new report. d) Using one of the functions defined in the external javascript file from the initialize() scripting method of the report causes a reference error. The functions from the external javascript file are not seen. Nov 5, 2010 10:09:17 AM org.eclipse.birt.report.engine.script.internal.ScriptExecutor addException WARNING: There are errors evaluating script "reportContext.getDesignHandle().title = params["par_title"].value + " - " + formatMonth(params["par_month"].value); ": ReferenceError: "formatMonth" is not defined. (/report/method[@name="initialize"]#2)
I forgot to mention something important ! The ReferenceError is emitted BUT the PDF file outputted, once ran and rendered, has the correct data. In my case, formatMonth as returned a value and that value is correctly displayed in my PDF. ReferenceError: "formatMonth" is not defined. (/report/method[@name="initialize"]#1) at org.eclipse.birt.report.engine.javascript.JavascriptEngine.evaluate(JavascriptEngine.java:287) at org.eclipse.birt.core.script.ScriptContext.evaluate(ScriptContext.java:154) at org.eclipse.birt.report.engine.executor.ExecutionContext.evaluate(ExecutionContext.java:743) at org.eclipse.birt.report.engine.executor.ExecutionContext.evaluate(ExecutionContext.java:672) at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.handleScriptInternal(ScriptExecutor.java:61) at org.eclipse.birt.report.engine.script.internal.ScriptExecutor.handleScript(ScriptExecutor.java:48) at org.eclipse.birt.report.engine.script.internal.ReportScriptExecutor.handleInitialize(ReportScriptExecutor.java:44) ... 12 more Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "formatMonth" is not defined. (/report/method[@name="initialize"]#1) at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3654) at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3632) at org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3717) at org.mozilla.javascript.ScriptRuntime.nameOrFunction(ScriptRuntime.java:1758) at org.mozilla.javascript.ScriptRuntime.getNameFunctionAndThis(ScriptRuntime.java:2135) at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:95) at org.mozilla.javascript.gen.c142._c0(/report/method[@name="initialize"]:1) at org.mozilla.javascript.gen.c142.call(/report/method[@name="initialize"]) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398) at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065) at org.mozilla.javascript.gen.c142.call(/report/method[@name="initialize"]) at org.mozilla.javascript.gen.c142.exec(/report/method[@name="initialize"]) at org.eclipse.birt.report.engine.javascript.JavascriptEngine.evaluate(JavascriptEngine.java:282) ... 18 more Julien
(In reply to comment #0) > Resource scripts assigned to report via Report - Resources - Javascript files > cannot be directly used in chart scripts. Calling any of the the resource > scripts generates ReferenceError when report is previewed. kalle, Could you give an example how you used resource scripts in Chart scripting?
(In reply to comment #2) > I forgot to mention something important ! > > The ReferenceError is emitted BUT the PDF file outputted, once ran and > rendered, has the correct data. In my case, formatMonth as returned a value and > that value is correctly displayed in my PDF. > > > ReferenceError: "formatMonth" is not defined. > (/report/method[@name="initialize"]#1) > at > org.eclipse.birt.report.engine.javascript.JavascriptEngine.evaluate(JavascriptEngine.java:287) > at > org.eclipse.birt.core.script.ScriptContext.evaluate(ScriptContext.java:154) > at > org.eclipse.birt.report.engine.executor.ExecutionContext.evaluate(ExecutionContext.java:743) > at > org.eclipse.birt.report.engine.executor.ExecutionContext.evaluate(ExecutionContext.java:672) > at > org.eclipse.birt.report.engine.script.internal.ScriptExecutor.handleScriptInternal(ScriptExecutor.java:61) > at > org.eclipse.birt.report.engine.script.internal.ScriptExecutor.handleScript(ScriptExecutor.java:48) > at > org.eclipse.birt.report.engine.script.internal.ReportScriptExecutor.handleInitialize(ReportScriptExecutor.java:44) > ... 12 more > Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "formatMonth" is > not defined. (/report/method[@name="initialize"]#1) > at > org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3654) > at > org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3632) > at > org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3717) > at > org.mozilla.javascript.ScriptRuntime.nameOrFunction(ScriptRuntime.java:1758) > at > org.mozilla.javascript.ScriptRuntime.getNameFunctionAndThis(ScriptRuntime.java:2135) > at org.mozilla.javascript.optimizer.OptRuntime.callName(OptRuntime.java:95) > at > org.mozilla.javascript.gen.c142._c0(/report/method[@name="initialize"]:1) > at org.mozilla.javascript.gen.c142.call(/report/method[@name="initialize"]) > at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398) > at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065) > at org.mozilla.javascript.gen.c142.call(/report/method[@name="initialize"]) > at org.mozilla.javascript.gen.c142.exec(/report/method[@name="initialize"]) > at > org.eclipse.birt.report.engine.javascript.JavascriptEngine.evaluate(JavascriptEngine.java:282) > ... 18 more > > Julien Julien, Could you also attache your report design and js file here? We can not reproduce this issue in our environment.
Created attachment 183450 [details] Report example causing chart reference error This report has an example about chart script error. Report contains two charts that are both setting own width in function afterDataSetFilled and use external script when doing so. Reference error is generated when script is used directly. Other chart uses script via getScriptable() and is just to indicate that script is valid.
Created attachment 183451 [details] Script file This file contains script used in example report.
Example report and script file are added. (In reply to comment #3) > (In reply to comment #0) > > Resource scripts assigned to report via Report - Resources - Javascript files > > cannot be directly used in chart scripts. Calling any of the the resource > > scripts generates ReferenceError when report is previewed. > > kalle, > > Could you give an example how you used resource scripts in Chart scripting?