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)
Automatically display report file name
linucksrox
Hi,
I was looking for a way to have a dynamic text field on a report or template that automatically shows the literal filename for the report design file for debugging purposes. Is there a way to do this, or would I need the report designers to manually type this in when creating a new report?
Find more posts tagged with
Comments
kclark
You can put this in your dynamic text box to output the file name<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
reportContext.getDesignHandle().fileName
</pre>
linucksrox
Perfect, that's exactly what I needed. Is there any good way to refine that, for example to show only report_filename.rptdesign without the absolute path? Where can I find the API with all of the functions and members?
Clement Wong
From this DevShare entry (<a class='bbc_url' href='
http://www.birt-exchange.org/org/devshare/designing-birt-reports/1330-get-folder-and-report-name/'>link</a>)
, to get the BIRT Design filename only use Javascript to parse out the folder path:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>var myReport = reportContext.getReportRunnable().getReportName();
myReport.substr(myReport.lastIndexOf('/') + 1);</pre>
linucksrox
One more question: how do I display a space instead of the %20 that shows up?
Clement Wong
<blockquote class='ipsBlockquote' data-author="'linucksrox'" data-cid="111526" data-time="1352922982" data-date="14 November 2012 - 12:56 PM"><p>
One more question: how do I display a space instead of the %20 that shows up?<br /></p></blockquote>
<br />
I'm not sure in what context you are seeing the escaped spaces (%20)s. However, you can easily use the replace method in Javascript to globally replace the %20s with actual spaces.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>var myReport = reportContext.getReportRunnable().getReportName();
myReport.substr(myReport.lastIndexOf('/') + 1).replace(/%20/gi, " ");</pre>