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)
Report Parameter based on data set value
phlyer
<p>Hi,</p>
<p> </p>
<p>I'm currently trying to generate a report parameter (boolean) based on the value of a data set column (string), which only has one row (string). <br>
</p>
<p>So what I was starting with, is the following script in onFetch of the data set:</p>
<pre class="_prettyXprint">
// onFetch
if(row["typ"] == "JOU") {
reportContext.setPersistentGlobalVariable("multipleUser", true);
}</pre>
<p>The report parameter itself is a boolean checkbox and in getDefaultValueList I want to catch the variable:</p>
<pre class="_prettyXprint">
// getDefaultValueList
reportContext.getPersistentGlobalVariable("multipleUser");</pre>
<p>As I am quite a beginner in JavaScript I am not sure if this is right and am hoping for some help regarding the code or even if my idea to do it like this is wrong.</p>
<p>I've seen in other posts that while generating the report with a parameter window, onFetch and getDefaultValueList are used more than once, but since I am only setting a value in one and retrieving it in the other, that shouldn't have an effect, right?<br><br><br>
Thank you in advance and best regards!</p>
Find more posts tagged with
Comments
Matthew L.
<p>Based on the requirements you mentioned, the Boolean+Check Box parameter option does not have a Dynamic option.</p>
<p>This causes the solution to become more difficult than it would seem.</p>
<p>The reason that the current code you provided doesn't work is because the "Data Set" never get's executed before the Parameter Screen appears (order of how elements execute).</p>
<p>Therefore the setPersistentGlobalVariable() does not contain a value to set the parameter.</p>
<p> </p>
<p>To work around this, we can manually execute the Data Set using some complex BIRT Design Engine JavaScript.</p>
<p>I've attached an example that will replicate the behavior you are wanting.</p>
<p>You should be able to "Copy and Paste" the code in the examples parameter's "getDefaultValueList" and place it in your own report parameter.</p>
<p>Then you should only need to change the first line in the code for the Data Set Name where your data is located.</p>
<pre class="_prettyXprint _lang-js">
//Change "Scripted Data Set" to your Data Set Name
var returnValue = QueryDataSet("Scripted Data Set");
</pre>
<p>Hopefully this help.</p>
<p>If you have any questions, please let me know.</p>
<p> </p>
KumarSaurav
<p>Thanks Matthew L. This solution helped me also in my project.</p>
phlyer
<p>Hi Mathew,</p>
<p> </p>
<p>this actually helped me a lot. Thank you very much. I just had to change one thing, maybe I explained it wrong earlier, but if someone else has the same problem:</p>
<p> </p>
<p>The dataset I am handling has quite a <strong>few columns</strong> but only <strong>one row</strong>, so I only needed to change the following line in your script for <span style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">"getDefaultValueList" to look in a specific column:</span></p>
<pre class="_prettyXprint">
var myVar = ri.getValue("typ");</pre>
<p>Thank you again!</p>
Matthew L.
<p>Great, I'm glad this solution works for you and that you could look through the code and make the correct changes according to your report requirements.</p>