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)
Parametrage file in Birt
mikaru
<p>Hello, i want know if this is possible to create a file which reunite a lot of variable which serve to set report birt in function this file?</p>
<p> </p>
<p><span>Basically I find out if it's possible to have an external parameter file the report called in any birt report and we can use the different variables included in this file.</span></p>
<p> </p>
<p><span>Cordialy, Mikaru.</span></p>
Find more posts tagged with
Comments
JFreeman
<p>You can create and external javascript file that can store and return/set the variables. You can then add that file as a resource to the report and call it when needed.</p>
PaulCooper
<p>I have come up with a solution for this using a special properties file for holding the defaults (defaults.properties) and a javascript file that holds the code to do the work. (defaults.js) You would need to add both of those as resources to every report. then add code like the following to replace a parameter with the default.</p>
<pre class="_prettyXprint">
var report_name = "product_sales";
var locale = reportContext.getLocale();
setupParameter("productCode", locale, report_name);</pre>
<p>Repeat the final line for each parameter you want to give defaults.</p>
<p> </p>
<p>Please note that this only replaces a parameter with its default if that parameter is null (including booleans).</p>
<p> </p>
<p>Attached is the default.js that contains the setupParameter function and a helper function. Also attached is an example defaults.properties file and a test report (test_defaults.rptdesign) that uses it. The default.properties has been attached as default.properties.txt and defaults.js as defaults.js.txt so that these files can be attached to this post. Please rename them back.</p>
<p> </p>
<p>The example report shows the value of each parameter but I have used a function (shiftDateForDaylightSaving()) to fix the dates and times for daylight saving (DST), if applicable, purely for display purposes as they would normally display as non-DST date-time even when DST would be in effect.</p>
<p> </p>
<p><strong>How to setup the defaults.properties file:</strong></p>
<p> </p>
<p>You can setup global defaults and/or report specific defaults. Global defaults have keys of the format:</p>
<p> </p>
<p> defaults.<parameter_name></p>
<p> </p>
<p>Report specific defaults have keys of the format:</p>
<p> </p>
<p> defaults.<report_name>.<parameter_name></p>
<p> </p>
<p>For any specific parameter the Report specific default is used if it exist. If it does not then the global default is used, again if it exists. The way the value for a key is interpreted depends on the data type of the parameter. So if the parameter hass a date-time data type then it will expect a value with date format with or without a time section. If the parameter is boolean then the values expected are "true" or "false" (case insenstive).</p>
<p>
Date values should be in the US format and should be in DST if it is in effect for that date/time:</p>
<p> </p>
<p> MM/dd/yyyy hh:mm:ss.sss</p>
<p> </p>
<p>I hope this is what you are looking for.</p>
<p> </p>
<p>Regards,</p>
<p> </p>
<p>Paul Cooper</p>