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)
How to use java script function to print its return value
BirtUser79
Hi,
In my report I have to perform some string operation and for that I am planning to write Java script function.
I am defining it in initialize event of rptdesign file.
e.g.
function myFun(str)
{
// perform task
return str;
}
My question is how to call this function so that I can print return value of it on report output. PDF is output format.
Birt version is 2.6
Thanks in advance.
Find more posts tagged with
Comments
mwilliams
You can do something like this in your initialize:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
myFunction = function myFun(str){
//perform task
return str;
}
</pre>
<br />
Then, in a dynamic text box, you can call the function with:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
myFunction(myValue);
</pre>
<br />
That should do it. Let me know.
BirtUser79
Thanks much! It worked.
Can you please let me know why we have to assign "myFunction = " to function and use it in layout. I thought by defining function and accessing it in layout should have solved the issue.
mwilliams
The best way to handle this would probably be to use an external .js file and use it as a resource for your report. Then, you should be able to just access it anywhere, and it'll be reusable, rather than copying the function into each report.
BirtRunn
Thank you, that would be better way.