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)
Determine the value of a parameter based on another parameter
ArK
<p>Hello,</p>
<p> </p>
<p>I have a problem with determining the value of a parameter based on another parameter.</p>
<p> </p>
<p>The case is as follows:</p>
<p> </p>
<p>A parameter, let's say param1 is given in the URL (WebViewer). With that parameter I can fetch data from a REST API which is then stored in another parameter, param2 (String).</p>
<p>The fetched parameter (param2) contains information needed in subsequent API calls that are performed in different data sets of the report.</p>
<p> </p>
<p>The problem:</p>
<p> </p>
<p>My report has parameters, a cascading parameter group and a crosstab. I was able to fetch the information needed in the beforeOpen method of the data source where i would update param2 with the value I was able to get using param1. param2 was then used by the first parameter of the cascading parameter group and all was well. To my surprise the data source's beforeOpen was run again and param2 was reset and param1 is now useless as it can be used only once. This causes all the following API calls to fail.</p>
<p> </p>
<p>I have tried several methods (variables, appContext, different phases of execution) to keep param2 stored throughout the report execution but so far I've not managed to do so. My guess is that it has something to do with the context the report has at given points in execution. </p>
<p> </p>
<p>Is there a way to initialize a parameter based on another between the call to WebViewer and parameter window and make sure it doesn't get reset? Note that param1 and param2 are hidden from the user and they are only used to enable the API calls that the data sets use!</p>
<p> </p>
<p>Unfortunately I can't provide you with the report as it contains sensitive information.</p>
<p> </p>
<p>-ArK</p>
Find more posts tagged with
Comments
Matthew L.
<p>Ark,</p>
<p> </p>
<p>Is there a particular reason you are doing this in a report parameter instead of building the API calls in the "beforeFactory" method of the report?</p>
<p>If the reason is only to execute a data set before the report runs, then try using the code via this example (probably the first/green example):</p>
<p><a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/35930-running-a-query-in-the-initalize/?p=133369'>http://developer.actuate.com/community/forum/index.php?/topic/35930-running-a-query-in-the-initalize/?p=133369</a></p>
;
<p> </p>
<p>It will allow you to execute a Data Set in the reports beforeFactory method and get the information you need. You can then assign the return values to a report variable (or a parameter) that can be used in elsewhere in the report before other elements execute.</p>
ArK
<p>Hello and thank you for your reply,</p>
<p> </p>
<p>I'm only using/updating two parameters (param1 & param2) in the data source and then using param2 in data sets so I'm not really doing anything 'in' a report parameter. I have 4 data sets, 3 of which are used to get parameter values (for param3, param4 and param5) so wouldn't making the API calls in the beforeFactory be a little late?</p>
<p>I was under the impression that initialize,onPrepare, beforeFactory etc. are executed after the user has been presented with the parameter window?</p>
<p> </p>
<p>In short:</p>
<ol><li>I need param1 to get param2.</li>
<li>I then need param2 to get data for 4 data sets. </li>
<li>Out of the 4 data sets 3 are connected to 'dynamic' parameters that the user will be prompted to select.</li>
</ol><p>It might very well be that I've misunderstood something so please clarify if I'm mistaken
</p>
<p> </p>
<p>Br, ArK</p>
Matthew L.
<p>Per your explanation, the beforeFactory would be too late (to populate the parameter screen for user input).</p>
<p>However, the parameter screen (presented before the report runs) is a separate process that doesn't tie into the BIRT engine easily (that I know of).</p>
<p>Also from what I can determine, the parameter screen doesn't update (or run additional code) when values are entered by the user.</p>
<p> </p>
<p>From my understanding you are wanting the following:</p>
<p>The user input parameter screen has 1 text input parameter (used for a REST API URL), and a 2nd parameter of cascading type with 3 sub values that are dynamically populated based on query results from a dynamically populated query provided by the REST API URL in parameter 1?</p>
<p>Correct?</p>
<p> </p>
<p>If not, could you provide an example report so that I can see the structure of what your are building?<br>
Please remove any private information from the example, as I don't need the example to run (though helpful), I just want to verify the structure of what your have setup so that I can fully understand what you are trying to accomplish.</p>
ArK
<p>The application that calls the WebViewer passes one parameter in the URL (<host>/birt-viewer/frameset?__report=report.rptdesign¶m1=value). Then a call is needed to be made 'behind the scenes' to get param2 from a REST API (the address is coded in the report) and in this call param1 is set as a header. The result of this call gives me the value for param2.</p>
<p> </p>
<p>Now I'm ready to populate the values for the data sets. This is done by calling REST APIs the address of which I also already know. The only issue with these calls is that I need to set param2 as a header in these calls. These are used for the cascading parameter that you spoke of.</p>
<p> </p>
<p>I hope this clarifies the isssue a bit - I know it's hard the get a decent understanding of what I'm trying to do here just based on my descriptions. Unfortunately I can't post the actual report here as it is quite vast and I wouldn't want to risk exposing even the tiniest bit of sensitive information.</p>