Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Use library (?) for common parameters and javascripts?
cmrdjr
Is it possible to use a library (or something) in a BIRT report so that parameters and the associated javascript for error checking do not have to be added individually for every report.
In SQR we put this kind of stuff in a file that is included with the main report. This is what I'd like to do with BIRT.
Right now I have the javascript for the parameter handling in beforeOpen method of each dataset in every report. Since these scripts are identical (or should be), I'd like to have the code in a single place.
It is the same with parameters. I'd like to be able to define a common set of report parameters that can be used in multiple reports. That way I can create 20 or so report parameters once and use the appropriate parameters in each report as needed.
Find more posts tagged with
Comments
UtahJerry
In the outline view, open the 'Library Explorer' or 'Resource Explorer' tab (depending on which version of BIRT you are using) and you can add almost any BIRT object to the Library. You can also create a report 'Template' with a lot of that information predefined in the template if you have a lot of similar reports. Look in the 'Documentation' section on the BIRT Exchange for detail or there are a couple of good books on BIRT available. "Practical Data Analysis and Reporting with BIRT" by John Ward has a good tutorial.
UtahJerry
There is also a good 30min presentation on Libraries and Templates in the archives of the BIRT Exchange Webinar archives.
cmrdjr
The main issue is that the report designs are not necessarily going to be similar enough to have a shared output template. I have just tried to add parameters to a new library and it does not allow me to do so. I have looked at the "Practical Data Analysis and Reporting with BIRT" by John Ward and it talks only about adding a datasource and then the other visual elements and parameters. My datasources are not going to be sharable I only want to share the parameters and some common scripting. Do I need to have a datasource that does something silly like select date from dual and then attach everything to it? How silly.
I'll have to check out the documentation section as well as the presentation you mention.
Maybe what I'm asking for is a java library and not a report library?
UtahJerry
I have a similar need and have added all of my most common report parameters to a library so that I have a consistent user interface. You should be able to add a report parameter to a report, then right click on the parameter and select the 'Export to Library' option. What version of BIRT are you using.
cmrdjr
I am using BIRT 2.3.0.
That is an option when I right click. WOW -- obviously I don't right click much!
Can you please now explain how to utilize this library within a report or is there an example online somewhere? It looks like I was able to get more than one parameter within the library by selecting the same library name when exporting the second parameter.
UtahJerry
Open your report in outline view in the bottom left panel and highlight the 'Report Parameters' section. Open the Resources tab, open the library and highlight the report parameter you want to use. Right click and select 'Add to Report' or just drag it down to the 'Report Parameters' section in the report outline view. (Screen shot attached.) Good luck! Jerry
cmrdjr
YEAH that works. <br />
<br />
Now on to the other question(s)....<br />
<br />
1. Can initialize scripts be added to a report library for use in the multiple reports. <br />
<br />
Here are some examples of things that I need to do for my common variables<br />
//round the value so that I only get a whole number<br />
params["FIS_UNIV_FISCAL_YR_VV"].value = Math.round(params["FIS_UNIV_FISCAL_YR_VV"].value);<br />
<br />
//Check to see if the incomming value is null or blank. Set a display variable accordingly otherwise strip out spaces, uppercase the value, and set a display varialbe.<br />
if ( params["RC_CD"].value == null || params["RC_CD"].value == "" ) {<br />
params["RC_CD"].value = "";<br />
RC_CD_DISPLAY = "ALL";<br />
}<br />
else {<br />
params["RC_CD"].value = params["RC_CD"].value.replace(/ /g, "");<br />
params["RC_CD"].value = params["RC_CD"].value.toUpperCase(); ;<br />
RC_CD_DISPLAY = params["RC_CD"];<br />
}<br />
<br />
// set a display variable<br />
if (params["INCLUDE_ORG"].value == "Y" ) <br />
{<br />
INCLUDE_ORG_DISPLAY = "YES";<br />
}else{<br />
INCLUDE_ORG_DISPLAY = "NO";<br />
}<br />
<br />
<br />
2. Can scripting that will be used change the sql in a datasoure be put into a library?<br />
<br />
example:<br />
var chartClause = " (1=1) ";<br />
var chart, whereChart;<br />
//This will see if a comman was included in the string<br />
if ( params["FIN_COA_CD"].value.match(",") )<br />
{<br />
// if there is a comman then split out the values and then surround them with single quotes<br />
var chart = params["FIN_COA_CD"].value.split(",");<br />
var chartLength = chart.length;<br />
for ( i=0; i < chartLength; i++ )<br />
{<br />
if ( i==0 ) {<br />
chartClause = "'" + chart
+ "' " ;<br />
}<br />
else {<br />
chartClause = chartClause + ", '" + chart
+ "'" ;<br />
};<br />
};<br />
<br />
} else {<br />
//this is a single value that was sent<br />
chartClause = "'" + params["FIN_COA_CD"] + "'";<br />
};<br />
//was a wild card used in the parameter string?<br />
if (params["FIN_COA_CD"].value.match("%") || params["FIN_COA_CD"].value.match("_")) {<br />
// if wildcard used then use a like statement<br />
chartClause= chartField + " like ( " + chartClause + " ) ";<br />
<br />
}else {<br />
//otherwise use an in statement<br />
chartClause = chartField + " in ( " + chartClause + " ) ";<br />
<br />
};<br />
//The whereChart clause will be used in the "this.queryText" replace statment below<br />
whereChart=chartClause;<br />
<br />
//Change the dataset query so that the approprate where clauses are used.<br />
//I would not expect this line of code to go into the library as it would be dataset specific<br />
this.queryText = this.queryText.replace("(1=0)",whereChart);